git-webhook-ci/Dockerfile

29 lines
568 B
Docker
Raw Permalink Normal View History

2024-04-29 21:29:05 +02:00
FROM golang:1.22 as builder
WORKDIR /app
2024-04-29 21:50:35 +02:00
# Copy the local package files to the container's workspace.
2024-04-29 21:29:05 +02:00
COPY go.mod go.sum ./
RUN go mod download
2024-04-29 21:50:35 +02:00
# Copy the project code into the container
COPY . .
2024-04-29 21:29:05 +02:00
2024-04-29 21:50:35 +02:00
# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -v -o git-webhook-ci
2024-04-29 21:29:05 +02:00
2024-04-29 21:50:35 +02:00
# Use a small Alpine Linux image
FROM alpine:latest
2024-04-29 21:29:05 +02:00
2024-04-29 21:50:35 +02:00
# Set the working directory
WORKDIR /root/
2024-04-29 21:29:05 +02:00
2024-04-29 21:50:35 +02:00
# Copy the binary from the builder stage
COPY --from=builder /app/git-webhook-ci .
2024-04-29 21:29:05 +02:00
2024-04-29 21:50:35 +02:00
# Document that the service listens on port 8080.
EXPOSE 8080
2024-04-29 21:29:05 +02:00
2024-04-29 21:50:35 +02:00
# Run the binary.
CMD ["./git-webhook-ci"]