CI/CD - build docker container
This commit is contained in:
26
Dockerfile
Normal file
26
Dockerfile
Normal 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"]
|
||||
Reference in New Issue
Block a user