Skip to content

Commit

Permalink
Merge pull request #27 from mrtazz/add-docker-image
Browse files Browse the repository at this point in the history
add docker build
  • Loading branch information
mrtazz committed Feb 26, 2020
2 parents 42f1561 + 78ebcb8 commit 1383019
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI
on: push
jobs:

build:
name: build and test
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1

- name: install dependencies
run: |
sudo wget https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-1-amd64.deb
sudo dpkg -i pandoc-2.7.3-1-amd64.deb
- name: build and run unit tests
run: make clean all test

- name: Run checkmake on Makefile
run: ./checkmake Makefile

docker:
needs: build
name: docker image build and release

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Build the Docker image
run: docker build . --file Dockerfile --tag mrtazz/checkmake:${GITHUB_SHA} --tag mrtazz/checkmake:latest

- name: push the docker image to docker hub
if: github.ref == 'refs/heads/master'
run: |
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login hub.docker.com -u mrtazz --password-stdin
docker push mrtazz/checkmake:${GITHUB_SHA}
docker push mrtazz/checkmake:latest
docker logout hub.docker.com
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.13 as builder

COPY . /checkmake

RUN cd /checkmake && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 make binaries

FROM alpine:3.9

USER nobody

COPY --from=builder /checkmake /
ENTRYPOINT ["./checkmake", "/Makefile"]
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MAN_TARGETS := $(patsubst man/man1/%.md,%,$(MAN_SOURCES))

INSTALLED_TARGETS = $(addprefix $(PREFIX)/bin/, $(TARGETS))
INSTALLED_MAN_TARGETS = $(addprefix $(PREFIX)/share/man/man1/, $(MAN_TARGETS))

# source, dependency and build definitions
DEPDIR = .d
MAKEDEPEND = echo "$@: $$(go list -f '{{ join .Deps "\n" }}' $< | awk '/github/ { gsub(/^github.com\/[a-z]*\/[a-z]*\//, ""); printf $$0"/*.go " }')" > $(DEPDIR)/$@.d
Expand All @@ -55,6 +55,8 @@ $(DEPDIR):
all: require $(TARGETS) $(MAN_TARGETS)
.DEFAULT_GOAL:=all

binaries: $(TARGETS)

require:
@echo "Checking the programs required for the build are installed..."
@pandoc --version >/dev/null 2>&1 || (echo "ERROR: pandoc is required."; exit 1)
Expand Down Expand Up @@ -147,4 +149,4 @@ pizza:
@echo "https://twitter.com/mrb_bk/status/760636493710983168"
@echo ""

.PHONY: all test rpm deb install local-install packages vendor coverage clean-deps clean clean-docs pizza
.PHONY: all test rpm deb install local-install packages vendor coverage clean-deps clean clean-docs pizza binaries
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ Options:
```

## Docker usage
Build the image, or pull it:
```sh
docker build . -t checker
```

Then run it with your Makefile attached, below is an example of it assuming the Makefile is in your current working directory:
```sh
docker run -v $(pwd)/Makefile:/Makefile checker
```

## Installation

### Requirements
Expand Down

0 comments on commit 1383019

Please sign in to comment.