Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit a214a4a

Browse files
committed
Adding build in docker with make
Adding docker.Makefile that simplifies building the code in docker Signed-off-by: Nick Adcock <[email protected]>
1 parent 4d2daf3 commit a214a4a

File tree

6 files changed

+45
-8
lines changed

6 files changed

+45
-8
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ jobs:
1010
uses: actions/checkout@v2
1111

1212
- name: Build
13-
run: docker build -t docker/github-actions .
14-
env:
15-
BUILDKIT_PROGRESS: plain
13+
run: make -f docker.Makefile

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github-actions
1+
bin/

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ RUN make ${MAKE_TARGET}
1717

1818

1919

20+
FROM scratch AS cli
21+
COPY --from=builder /src/bin/github-actions github-actions
22+
23+
24+
2025
FROM alpine:${ALPINE_VERSION}
2126

22-
COPY --from=builder /src/github-actions /github-actions
27+
COPY --from=builder /src/bin/github-actions /github-actions
2328

24-
ENTRYPOINT ["/github-actions"]
29+
ENTRYPOINT ["/github-actions"]

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
all: build lint test
22

33
build:
4-
go build -o github-actions ./cmd
4+
@$(call mkdir,bin)
5+
go build -o bin/github-actions ./cmd
56

67
lint:
78
golangci-lint run --config golangci.yml ./...

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
# github-actions
2-
Core code for all Docker's github actions
2+
The core code base for Docker's GitHub Actions (https://github.com/features/actions). This code is used to build the docker/github-actions image that provides the functionality used by the published Docker GitHub Actions
3+
4+
5+
## Building github-actions
6+
The code is written in Go v1.13 with `go mod`. It can be built locally using the `Makefile` or in docker using the `docker.Makefile`.
7+
8+
`make -f docker.Makefile` will build the code, check the linting using golangci-lint, run the go tests, and build the image with a tag of docker/github-actions:latest
9+
10+
`make -f docker.Makefile TAG=foo` will build the code, check the linting using golangci-lint, run the go tests, and build the image with a tag of docker/github-actions:foo
11+
12+
`make -f docker.Makefile image` will build the github-actions image without a tag and without running test or lint checking
13+
14+
`make -f docker.Makefile cli` will build the cli and copy it to `./bin/github-actions`
15+
16+
`make -f docker.Makefile test` will run the go tests

docker.Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
TAG ?= latest
2+
STATIC_FLAGS = BUILDKIT_PROGRESS=plain
3+
DOCKER_BUILD = $(STATIC_FLAGS) docker build
4+
5+
all:
6+
$(DOCKER_BUILD) -t docker/github-actions:$(TAG) .
7+
8+
image:
9+
$(DOCKER_BUILD) -t docker/github-actions:$(TAG) --build-arg MAKE_TARGET=build .
10+
11+
cli:
12+
@$(call mkdir,bin)
13+
$(DOCKER_BUILD) -t github-actions-cli --target=cli --output type=local,dest=./bin/ --build-arg MAKE_TARGET=build .
14+
15+
lint:
16+
$(DOCKER_BUILD) -t github-actions-lint --build-arg MAKE_TARGET=lint .
17+
18+
test:
19+
$(DOCKER_BUILD) -t github-actions-test --build-arg MAKE_TARGET=test .

0 commit comments

Comments
 (0)