-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (23 loc) · 751 Bytes
/
Dockerfile
File metadata and controls
34 lines (23 loc) · 751 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
ARG REPO_URL
# Stage 1: Build the Go application
FROM ${REPO_URL}/golang:1.23.3-alpine AS builder
# Set the working directory
WORKDIR /app
# Copy the Go modules manifests if they exist
COPY /go.mod /go.sum ./
# Download the Go modules if the manifests were copied
RUN if [ -f go.mod ]; then go mod download; fi
# Copy the source code
COPY . .
# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o go-server .
# Stage 2: Create the final image
FROM ${REPO_URL}/alpine:latest
# Set the working directory
WORKDIR /app
# Copy the built binary from the builder stage
COPY --from=builder /app/go-server .
# Expose the port the application runs on
EXPOSE 9001
# Command to run the application
CMD ["./go-server"]