Eric Bower
·
07 Nov 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
9RUN git clone https://codeberg.org/emersion/soju.git
10
11COPY subscriber-change.diff .
12
13WORKDIR /app/soju
14
15RUN git apply ../subscriber-change.diff
16
17RUN --mount=type=cache,target=/go/pkg/,rw \
18 --mount=type=cache,target=/root/.cache/,rw \
19 go mod download
20
21FROM builder-deps AS builder
22
23COPY . .
24
25ARG APP=prose
26ARG TARGETOS
27ARG TARGETARCH
28
29ENV CGO_ENABLED=0
30ENV GOFLAGS="-tags=moderncsqlite"
31ENV LDFLAGS="-s -w"
32
33ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
34
35RUN --mount=type=cache,target=/go/pkg/,rw \
36 --mount=type=cache,target=/root/.cache/,rw \
37 go build -ldflags "$LDFLAGS" ./cmd/soju
38
39RUN --mount=type=cache,target=/go/pkg/,rw \
40 --mount=type=cache,target=/root/.cache/,rw \
41 go build -ldflags "$LDFLAGS" ./cmd/sojuctl
42
43FROM scratch
44
45WORKDIR /app
46
47COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
48COPY --from=builder /app/soju/soju .
49COPY --from=builder /app/soju/sojuctl .
50
51COPY soju.config .
52
53EXPOSE 6697
54EXPOSE 8080
55
56ENTRYPOINT ["/app/soju", "-config", "/app/soju.config"]