task_manager/Dockerfile
2025-03-21 21:47:32 +03:00

29 lines
689 B
Docker

# syntax=docker/dockerfile:1.5
# Build stage
ARG GO_VERSION=1.24
FROM golang:${GO_VERSION} AS builder
# Set the working directory
WORKDIR /app
# Cache dependencies and build the application
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,target=. \
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /task-manager ./cmd/main.go
# Final stage
FROM scratch AS final
# Set the working directory
WORKDIR /app
# Copy the built binary from the builder stage
COPY --from=builder /task-manager ./
# Expose the application port
EXPOSE 8080
# Set the default command to run the application
CMD ["./task-manager"]