Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 34bef05

Browse files
committed
Make resulting docker file smaller
By better utilizing built stages I can skip copying the source code and dependencies, only using golang alpine image + curl + binary.
1 parent 2994936 commit 34bef05

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
FROM golang:1.23-alpine AS deps
2-
COPY go.mod go.sum ./
3-
RUN go mod download
4-
51
FROM golang:1.23-alpine AS golang-with-curl
62
RUN apk --no-cache add curl
73

8-
FROM golang-with-curl
4+
FROM golang-with-curl AS deps
5+
WORKDIR /app
6+
COPY go.mod go.sum ./
7+
RUN go mod download
8+
9+
FROM deps AS build
910
WORKDIR /app
10-
COPY --from=deps /go/pkg/mod /go/pkg/mod
1111
COPY go.mod .
1212
COPY go.sum .
1313
COPY common common
1414

1515
ARG DAY
1616
COPY solutions/day${DAY} solutions/day${DAY}
1717
RUN go build -o app ./solutions/day${DAY}
18-
EXPOSE 3000
1918

19+
FROM golang-with-curl
20+
WORKDIR /app
21+
COPY --from=build /app/app .
22+
23+
EXPOSE 3000
24+
EXPOSE 50051
2025
HEALTHCHECK \
2126
--start-interval=10s \
2227
--interval=10s \

0 commit comments

Comments
 (0)