-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (25 loc) · 728 Bytes
/
Dockerfile
File metadata and controls
37 lines (25 loc) · 728 Bytes
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
28
29
30
31
32
33
34
35
36
37
FROM golang:1.21.3 as builder
WORKDIR /usr/src/app
# COPY go.sum ./
COPY go.mod ./
RUN go mod download && go mod verify
COPY . .
RUN go build -o clean
FROM alpine:latest
COPY --from=builder /usr/src/app/clean /clean
CMD ["/clean"]
# альтернативный вариант
# FROM golang:onbuild AS build
# WORKDIR /build
# COPY . .
# RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o ./app
# FROM ubuntu:20.04 AS ubuntu
# RUN apt-get update
# RUN DEBIAN_FRONTEND=noninteractive apt-get install -y upx
# RUN apt-get clean && \
# rm -rf /var/lib/apt/lists/*
# COPY --from=build /build/app /build/app
# RUN upx /build/app
# FROM scratch
# COPY --from=ubuntu /build/app /build/app
# ENTRYPOINT ["/build/app"]