-
Notifications
You must be signed in to change notification settings - Fork 28
/
Dockerfile
73 lines (46 loc) · 1.5 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM --platform=$BUILDPLATFORM golang:1.23 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 --mount=type=cache,target=/go/pkg/,rw \
--mount=type=cache,target=/root/.cache/,rw \
go mod download
FROM builder-deps AS builder-web
COPY . .
ARG APP=prose
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0
ENV LDFLAGS="-s -w"
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
RUN --mount=type=cache,target=/go/pkg/,rw \
--mount=type=cache,target=/root/.cache/,rw \
go build -ldflags "$LDFLAGS" -o /go/bin/${APP}-web ./cmd/${APP}/web
FROM builder-deps AS builder-ssh
COPY . .
ARG APP=prose
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0
ENV LDFLAGS="-s -w"
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
RUN --mount=type=cache,target=/go/pkg/,rw \
--mount=type=cache,target=/root/.cache/,rw \
go build -ldflags "$LDFLAGS" -o /go/bin/${APP}-ssh ./cmd/${APP}/ssh
FROM scratch AS release-web
WORKDIR /app
ARG APP=prose
COPY --from=builder-web /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder-web /go/bin/${APP}-web ./web
COPY --from=builder-web /app/${APP}/html ./${APP}/html
COPY --from=builder-web /app/${APP}/public ./${APP}/public
ENTRYPOINT ["/app/web"]
FROM scratch AS release-ssh
WORKDIR /app
ENV TERM="xterm-256color"
ARG APP=prose
COPY --from=builder-ssh /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder-ssh /go/bin/${APP}-ssh ./ssh
ENTRYPOINT ["/app/ssh"]