-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
58 lines (34 loc) · 1.01 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
FROM --platform=$BUILDPLATFORM golang:1.22 as builder-deps
LABEL maintainer="Pico Maintainers <[email protected]>"
WORKDIR /app
RUN apt-get update
RUN apt-get install -y git ca-certificates
COPY go.* ./
RUN go mod download
FROM builder-deps as builder-web
COPY . .
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0
ENV LDFLAGS="-s -w"
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
RUN go build -ldflags "$LDFLAGS" -o /go/bin/web ./cmd/web
FROM builder-deps as builder-ssh
COPY . .
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0
ENV LDFLAGS="-s -w"
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
RUN go build -ldflags "$LDFLAGS" -o /go/bin/ssh ./cmd/ssh
FROM scratch as release-web
WORKDIR /app
COPY --from=builder-web /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder-web /go/bin/web ./web
CMD ["/app/web"]
FROM scratch as release-ssh
WORKDIR /app
ENV TERM="xterm-256color"
COPY --from=builder-ssh /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder-ssh /go/bin/ssh ./ssh
CMD ["/app/ssh"]