Files
dashboard/backend/Dockerfile
jafreli 49e118b09c
Some checks failed
Build and Push Docker Images / build-and-push-backend (push) Failing after 1m28s
Build and Push Docker Images / build-and-push-frontend (push) Failing after 25s
Docker and Workflow
2026-01-31 00:45:48 +01:00

31 lines
740 B
Docker

# Stage 1: Build the Go application
FROM golang:1.22-alpine AS builder
WORKDIR /app
# Copy go.mod and go.sum files to download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the application source code
COPY . .
# Build the application
# CGO_ENABLED=0 is important for a clean static build for Alpine
# -o main specifies the output file name
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# Stage 2: Create the final lightweight image
FROM alpine:latest
WORKDIR /root/
# Copy the built binary from the builder stage
COPY --from=builder /app/main .
# Expose port 8080 (you can change this if your app uses a different port)
EXPOSE 8080
# Command to run the executable
CMD ["./main"]