Skip to content

Commit 9414e01

Browse files
author
Sebastian Gumprich
committed
use separate dockerfile for building and running
1 parent 69a6304 commit 9414e01

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

Dockerfile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
ARG DISTROLESS_IMAGE=gcr.io/distroless/base
1+
# syntax=docker/dockerfile:1
2+
FROM golang:1.19-alpine AS build-env
3+
RUN mkdir -p /go/src/confluence-gardner
24

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

7-
# Copy our static executable
8-
COPY confluence-gardner /confluence-gardner
9+
COPY go.* ./
10+
RUN go mod download
911

10-
# Run the hello binary.
11-
ENTRYPOINT ["/confluence-gardner"]
12+
WORKDIR /go/src/confluence-gardner
13+
ADD conf conf
14+
COPY *.go ./
15+
RUN go build -o confluence-gardner
16+
17+
# final stage
18+
FROM alpine:latest
19+
COPY --from=build-env /go/src/confluence-gardner/confluence-gardner /usr/local/bin/confluence-gardner
20+
RUN mkdir -p /output
21+
ENV DIRECTORY /output
22+
ENTRYPOINT ["confluence-gardner"]

goreleaser.dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ARG DISTROLESS_IMAGE=gcr.io/distroless/base
2+
3+
# using base nonroot image
4+
# user:group is nobody:nobody, uid:gid = 65534:65534
5+
FROM ${DISTROLESS_IMAGE}
6+
7+
# Copy our static executable
8+
COPY confluence-gardner /confluence-gardner
9+
10+
# Run the hello binary.
11+
ENTRYPOINT ["/confluence-gardner"]

0 commit comments

Comments
 (0)