Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (35 loc) · 1.55 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (35 loc) · 1.55 KB
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
# Build Stage
FROM --platform=$BUILDPLATFORM golang:1.26.10-alpine@sha256:27f2d3b83cfc5803c8078f8e730af0f7c431bf067afaec8f60a36fb763187cba AS builder
ARG TARGETARCH
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache git wget ca-certificates tzdata
# Download the wait script (architecture-specific)
RUN if [ "$TARGETARCH" = "arm64" ]; then \
wget -O /wait https://github.com/ufoscout/docker-compose-wait/releases/download/2.12.1/wait_aarch64; \
elif [ "$TARGETARCH" = "amd64" ]; then \
wget -O /wait https://github.com/ufoscout/docker-compose-wait/releases/download/2.12.1/wait; \
else \
echo "Unsupported architecture: $TARGETARCH" && exit 1; \
fi && chmod +x /wait
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the application for target architecture
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o matrix-adapter ./cmd/adapter
# Final Stage - Distroless
FROM gcr.io/distroless/static-debian13:nonroot@sha256:f7f8f729987ad0fdf6b05eeeae94b26e6a0f613bdf46feea7fc40f7bd72953e6 AS runtime
WORKDIR /app
# Copy CA certificates and timezone data from builder
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# Copy wait script from builder
COPY --from=builder /wait /wait
# Copy binary from builder
COPY --from=builder /app/matrix-adapter .
# Expose AppService port (Matrix transactions, health checks, webhooks)
EXPOSE 8280
ENTRYPOINT ["/app/matrix-adapter"]