# Build image for building the application FROM golang:1.23.1-bookworm AS builder WORKDIR /app # Install required packages (включая ca-certificates) RUN apt-get update && apt-get install -y \ git \ curl \ ca-certificates && \ update-ca-certificates # Install migrate RUN curl -L https://github.com/golang-migrate/migrate/releases/download/v4.18.1/migrate.linux-amd64.tar.gz | tar xvz && \ mv migrate /usr/local/bin/migrate # Copy go.mod and go.sum for caching dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the source code COPY . ./ # Build the application RUN CGO_ENABLED=0 GOOS=linux go build -o main ./cmd/main.go # Minimal image for running the application FROM debian:bookworm-slim WORKDIR /app # Устанавливаем ca-certificates в финальный образ RUN apt-get update && \ apt-get install -y --no-install-recommends ca-certificates && \ rm -rf /var/lib/apt/lists/* # Create virtual environment ENV PATH="/opt/venv/bin:$PATH" # Copy application files COPY --from=builder /app/main . COPY --from=builder /usr/local/bin/migrate /usr/local/bin/migrate COPY --from=builder /app/migrations ./migrations # Create directories RUN mkdir -p ./docs # Copy entrypoint COPY docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh EXPOSE 6589 ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]