-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (33 loc) · 988 Bytes
/
Dockerfile
File metadata and controls
43 lines (33 loc) · 988 Bytes
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
#
# local testing build:
# > docker build -t tsidp-server:local .
#
# To build for a container for linux/amd64:
# docker buildx build --platform linux/amd64 -t tsidp-server:amd64 --load .
# Build stage
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
WORKDIR /app
# BuildKit will set these automatically when using buildx
ARG TARGETOS
ARG TARGETARCH
# Copy go mod files from root
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the entire project
COPY . ./
# Build the binary for the target platform
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
go build -a -installsuffix cgo -o tsidp-server .
# Final stage
FROM alpine:3.22
RUN apk --no-cache add ca-certificates
WORKDIR /app
RUN mkdir -p /data
RUN addgroup -g 1001 -S app && \
adduser -u 1001 -S app && \
chown app:app /data
# Copy the binary from builder
COPY --from=builder /app/tsidp-server /tsidp-server
USER app:app
ENTRYPOINT ["/tsidp-server"]