Files
wagfarm/wagfarm-api/Dockerfile
2025-04-09 20:37:07 +02:00

33 lines
694 B
Docker

# Use official Golang image
FROM golang:1.20-alpine as builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum are not changed
RUN go mod download
# Copy the source code into the container
COPY src src
# Build the Go app
RUN go build -o main src
# Start a new stage from a smaller image
FROM alpine:latest
# Install required libraries
RUN apk --no-cache add ca-certificates
# Copy the pre-built binary file from the builder stage
COPY --from=builder /app/main .
# Expose the API port
EXPOSE 8089
# Run the Go app
CMD ["./main"]