Skip to content

Commit

Permalink
multistage build (enhancement) (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisandreenko committed Oct 13, 2023
1 parent a70c527 commit 17caf86
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Repo config
.git

# IDE configs
.vscode
.idea

# Environment variables
.env

# Other
website
grafana
integration_test
prometheus
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ dockers:
- image_templates:
- '{{ if .IsSnapshot }}ghcr.io/{{ end }}ecadlabs/signatory:{{ if .IsSnapshot }}{{ .FullCommit }}{{ else }}{{ .Tag }}{{ end }}-amd64'
- '{{ if not .IsSnapshot }}ecadlabs/signatory:latest-amd64{{ end }}'
dockerfile: Dockerfile
dockerfile: goreleaser.dockerfile
use: buildx
build_flag_templates:
- "--pull"
Expand All @@ -256,7 +256,7 @@ dockers:
- image_templates:
- '{{ if .IsSnapshot }}ghcr.io/{{ end }}ecadlabs/signatory:{{ if .IsSnapshot }}{{ .FullCommit }}{{ else }}{{ .Tag }}{{ end }}-arm64'
- '{{ if not .IsSnapshot }}ecadlabs/signatory:latest-arm64{{ end }}'
dockerfile: Dockerfile
dockerfile: goreleaser.dockerfile
use: buildx
build_flag_templates:
- "--pull"
Expand All @@ -270,7 +270,7 @@ dockers:
- image_templates:
- '{{ if .IsSnapshot }}ghcr.io/{{ end }}ecadlabs/signatory:{{ if .IsSnapshot }}{{ .FullCommit }}{{ else }}{{ .Tag }}{{ end }}-armv7'
- '{{ if not .IsSnapshot }}ecadlabs/signatory:latest-armv7{{ end }}'
dockerfile: Dockerfile
dockerfile: goreleaser.dockerfile
use: buildx
build_flag_templates:
- "--pull"
Expand Down
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
FROM ubuntu:22.04
RUN apt-get update
RUN apt-get install -y curl apt-transport-https
RUN apt-get clean
FROM golang:1.21-bullseye AS builder
RUN apt-get update && apt-get install
ADD . /signatory
WORKDIR /signatory
RUN make

COPY ./signatory /bin
COPY ./signatory-cli /bin

ENTRYPOINT ["/bin/signatory"]
FROM debian:buster-slim
WORKDIR /signatory
RUN apt update -y \
&& apt install -y curl apt-transport-https\
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /signatory/signatory.yaml /signatory/signatory.yaml
COPY --from=builder /signatory/signatory /usr/bin/signatory
COPY --from=builder /signatory/signatory-cli /usr/bin/signatory-cli

ENTRYPOINT ["/usr/bin/signatory"]
CMD [ "-c", "/signatory/signatory.yaml" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ signatory-cli:

.PHONY: container
container: signatory signatory-cli
docker build -t ecadlabs/signatory:$(CONTAINER_TAG) .
docker build -t ecadlabs/signatory:$(CONTAINER_TAG) -f goreleaser.dockerfile .

clean:
rm signatory signatory-cli
Expand Down
9 changes: 9 additions & 0 deletions goreleaser.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:22.04
RUN apt-get update
RUN apt-get install -y curl apt-transport-https
RUN apt-get clean

COPY ./signatory /bin
COPY ./signatory-cli /bin

ENTRYPOINT ["/bin/signatory"]

0 comments on commit 17caf86

Please sign in to comment.