forked from linuxfoundation/lfx-v2-auth-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (26 loc) · 1.08 KB
/
Dockerfile
File metadata and controls
38 lines (26 loc) · 1.08 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
# Copyright The Linux Foundation and each contributor to LFX.
# SPDX-License-Identifier: MIT
# checkov:skip=CKV_DOCKER_7:No free access to Chainguard versioned labels.
# hadolint global ignore=DL3007
FROM cgr.dev/chainguard/go:latest AS builder
# Set necessary environment variables needed for our image. Allow building to
# other architectures via cross-compilation build-arg.
ARG TARGETARCH
ENV CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH
# Move to working directory /build
WORKDIR /build
# Download dependencies to go modules cache
COPY go.mod go.sum ./
RUN go mod download
# Copy the code into the container
COPY . .
# Generate API code and build the packages
RUN go build -o /go/bin/auth-service -trimpath -ldflags="-w -s" github.com/linuxfoundation/lfx-v2-auth-service/cmd/server
# Run our go binary standalone
FROM cgr.dev/chainguard/static:latest
# Implicit with base image; setting explicitly for linters.
USER nonroot
# Expose port 8080 for health checks and metrics (if needed)
EXPOSE 8080
COPY --from=builder /go/bin/auth-service /cmd/auth-service
ENTRYPOINT ["/cmd/auth-service"]