add dockerfile for backend && update docker-compose.yml

This commit is contained in:
Egor Pozharov
2026-04-14 15:39:21 +06:00
parent 10233808f4
commit d3cd92b9f3
2 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# Stage 1: Builder
FROM golang:1.25-alpine AS builder
WORKDIR /app
# Install git and build dependencies
RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -o api ./cmd/api
# Stage 2: Production
FROM alpine:latest AS production
RUN apk --no-cache add ca-certificates
WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/api .
# Copy migrations
COPY internal/db/migrations ./migrations
EXPOSE 8080
CMD ["./api"]