-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
27 lines (24 loc) · 680 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
############################
# STEP 1 build base
############################
FROM golang:1.21-alpine3.18 AS build-base
WORKDIR /build
COPY ["go.mod", "go.sum", "./"]
RUN go mod download -x
############################
# STEP 2 image base
############################
FROM alpine:3.18 as image-base
WORKDIR /app
ENTRYPOINT [ "service" ]
############################
# STEP 3 build executable
############################
FROM build-base AS builder
COPY . .
RUN GOOS=linux GOARCH=amd64 go build -o /build/bin/service main.go
############################
# STEP 4 Finalize image
############################
FROM image-base
COPY --from=builder /build/bin/service /usr/bin/service