-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
32 lines (25 loc) · 884 Bytes
/
Dockerfile
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
# =============================================================================
# BUILD CONTAINER
# =============================================================================
FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS build
# Create application directory
RUN mkdir /app
ADD . /app/
WORKDIR /app
# Build the application
RUN CGO_ENABLED=0 go mod download
RUN CGO_ENABLED=0 go build -o run .
# =============================================================================
# RUNTIME CONTAINER
# =============================================================================
FROM --platform=$BUILDPLATFORM alpine:latest
# Create application directory
RUN mkdir /app
WORKDIR /app
# Add the execution user
RUN adduser -S -D -H -h /app execuser
USER execuser
# Copy binary from build container
COPY --from=build /app/run /app/run
# Run the application
ENTRYPOINT ["./run"]