confetti-api/Dockerfile
hook-lord a41df57bff
Some checks failed
Build and Push / build (push) Failing after 1m33s
added gitignore and fixed dockerfile as only std lib is used
2024-09-14 00:29:16 +02:00

34 lines
761 B
Docker

# Use a multi-stage build to create a minimal Docker image
# Stage 1: Build the Go application
FROM golang:1.23-alpine as builder
# Set the working directory inside the container
WORKDIR /app
# Copy go.mod and go.sum files if you have them
COPY go.mod ./
# Download all dependencies
RUN go mod download
# Copy the source code into the container
COPY . .
# Build the Go application
RUN go build -o confetti-api main.go
# Stage 2: Create a minimal image with the application binary
FROM alpine:latest
# Set the working directory inside the container
WORKDIR /root/
# Copy the binary from the builder stage
COPY --from=builder /app/confetti-api .
# Expose port 8080 for the application
EXPOSE 8080
# Command to run the application
CMD ["./confetti-api"]