feat: implement multi-stage Dockerfile for deployment infrastructure
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
3a9dd24e33
commit
69312022ea
5 files changed
+224
-2
No files matched your search
+38
@@ -0,0 +1,38 @@
|
||||
# Builder stage
|
||||
FROM golang:1.26-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go.mod and go.sum
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build api and cron binaries
|
||||
RUN go build -o api ./cmd/api
|
||||
RUN go build -o cron ./cmd/cron
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy binaries from builder
|
||||
COPY --from=builder /app/api /app/api
|
||||
COPY --from=builder /app/cron /app/cron
|
||||
|
||||
# Set environment variables
|
||||
ENV DB_DSN="postgres://postgres:postgres@postgres:5432/trip_planner?sslmode=disable"
|
||||
ENV REDIS_ADDR="redis:6379"
|
||||
ENV YANDEX_API_KEY=""
|
||||
ENV TRIP_PLANNER_ADMIN_API_KEY=""
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Set entrypoint for api service (default)
|
||||
ENTRYPOINT ["/app/api"]
|
||||
Reference in new issue
Block a user