repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

Antonio Mika · 02 Oct 24

Dockerfile

 1FROM --platform=$BUILDPLATFORM golang:1.23 AS builder-deps
 2LABEL maintainer="Pico Maintainers <hello@pico.sh>"
 3
 4WORKDIR /app
 5
 6RUN apt-get update
 7RUN apt-get install -y git ca-certificates
 8
 9COPY go.* ./
10
11RUN --mount=type=cache,target=/go/pkg/,rw \
12  --mount=type=cache,target=/root/.cache/,rw \
13  go mod download
14
15FROM builder-deps AS builder-web
16
17COPY . .
18
19ARG APP=prose
20ARG TARGETOS
21ARG TARGETARCH
22
23ENV CGO_ENABLED=0
24ENV LDFLAGS="-s -w"
25
26ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
27
28RUN --mount=type=cache,target=/go/pkg/,rw \
29  --mount=type=cache,target=/root/.cache/,rw \
30  go build -ldflags "$LDFLAGS" -o /go/bin/${APP}-web ./cmd/${APP}/web
31
32FROM builder-deps AS builder-ssh
33
34COPY . .
35
36ARG APP=prose
37ARG TARGETOS
38ARG TARGETARCH
39
40ENV CGO_ENABLED=0
41ENV LDFLAGS="-s -w"
42
43ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
44
45RUN --mount=type=cache,target=/go/pkg/,rw \
46  --mount=type=cache,target=/root/.cache/,rw \
47  go build -ldflags "$LDFLAGS" -o /go/bin/${APP}-ssh ./cmd/${APP}/ssh
48
49FROM scratch AS release-web
50
51WORKDIR /app
52
53ARG APP=prose
54
55COPY --from=builder-web /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
56COPY --from=builder-web /go/bin/${APP}-web ./web
57COPY --from=builder-web /app/${APP}/html ./${APP}/html
58COPY --from=builder-web /app/${APP}/public ./${APP}/public
59
60ENTRYPOINT ["/app/web"]
61
62FROM scratch AS release-ssh
63
64WORKDIR /app
65ENV TERM="xterm-256color"
66
67ARG APP=prose
68
69COPY --from=builder-ssh /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
70COPY --from=builder-ssh /go/bin/${APP}-ssh ./ssh
71
72
73ENTRYPOINT ["/app/ssh"]