Files
knet/dockerfile
JurajKubrican ff0df644af fix
2024-12-30 16:38:09 +01:00

35 lines
674 B
Plaintext

# Step 1: Build the Go binary in a separate stage
FROM golang:1.23-alpine AS builder
RUN apk update; apk add --no-cache gcc musl-dev
ENV GCO_ENABLED=1
# ENV GOOS=linux
# ENV GOARCH=amd64
# Set the working directory
WORKDIR /app
# Copy the Go module files
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the application code
COPY . .
# Build the Go binary with static linking for Linux
RUN go build -o /server ./src
FROM scratch
# Set the current working directory inside the container
WORKDIR /app
COPY . .
COPY --from=builder server ./
# Command to run the executable
CMD ["./server"]
# Expose the port on which the Go server will run
EXPOSE 54321