CI/CD - build docker container

This commit is contained in:
2026-06-02 19:26:35 +02:00
parent 90001720d8
commit e9230e6240
3 changed files with 72 additions and 0 deletions

26
Dockerfile Normal file
View File

@@ -0,0 +1,26 @@
FROM golang:1.26-bookworm AS base
# Move to working directory /app
WORKDIR /app
# Copy the go.mod and go.sum files to the /app directory
COPY go.mod go.sum ./
# Install dependencies
RUN go mod download
# Copy the entire source code into the container
COPY . .
# Build the application
RUN go build -o shortener
FROM golang:1.26-bookworm AS runner
COPY --from=base /app/shortener /app/shortener
# Document the port that may need to be published
EXPOSE 8000
# Start the application
CMD ["/app/shortener"]