Skip to content

Commit

Permalink
use separate dockerfile for building and running
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Gumprich committed Jul 27, 2023
1 parent 69a6304 commit 9414e01
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
ARG DISTROLESS_IMAGE=gcr.io/distroless/base
# syntax=docker/dockerfile:1
FROM golang:1.19-alpine AS build-env
RUN mkdir -p /go/src/confluence-gardner

# using base nonroot image
# user:group is nobody:nobody, uid:gid = 65534:65534
FROM ${DISTROLESS_IMAGE}
# Copy the module files first and then download the dependencies. If this
# doesn't change, we won't need to do this again in future builds.
WORKDIR /go/src/confluence-gardner

# Copy our static executable
COPY confluence-gardner /confluence-gardner
COPY go.* ./
RUN go mod download

# Run the hello binary.
ENTRYPOINT ["/confluence-gardner"]
WORKDIR /go/src/confluence-gardner
ADD conf conf
COPY *.go ./
RUN go build -o confluence-gardner

# final stage
FROM alpine:latest
COPY --from=build-env /go/src/confluence-gardner/confluence-gardner /usr/local/bin/confluence-gardner
RUN mkdir -p /output
ENV DIRECTORY /output
ENTRYPOINT ["confluence-gardner"]
11 changes: 11 additions & 0 deletions goreleaser.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG DISTROLESS_IMAGE=gcr.io/distroless/base

# using base nonroot image
# user:group is nobody:nobody, uid:gid = 65534:65534
FROM ${DISTROLESS_IMAGE}

# Copy our static executable
COPY confluence-gardner /confluence-gardner

# Run the hello binary.
ENTRYPOINT ["/confluence-gardner"]

0 comments on commit 9414e01

Please sign in to comment.