/
AngelCareMe
/
task_queue
Обзор
Документация
Войти
/
AngelCareMe
/
task_queue
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docker/api/Dockerfile
54 строки
1 KB
AngelCareMe
done
28 июл 2025, 21:07
28 июл 2025, 21:07
c70014b
Код
Авторство
О чём код?
# Build stage FROM golang:1.24.1-alpine AS builder # Install git (needed for go mod download) RUN apk add --no-cache git # Set working directory WORKDIR /app # Copy go mod and sum files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy source code COPY . . # Build the binary RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o api ./cmd/api # Final stage FROM alpine:latest # Install ca-certificates for HTTPS requests RUN apk --no-cache add ca-certificates # Create non-root user RUN adduser -D -s /bin/sh appuser # Set working directory WORKDIR /app # Copy binary from builder stage COPY --from=builder /app/api . # Copy config file COPY config.yaml . # Change ownership to non-root user RUN chown -R appuser:appuser /app # Switch to non-root user USER appuser # Expose port EXPOSE 8080 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --quiet --tries=1 --spider http://localhost:8080/api/v1/health || exit 1 # Run the binary CMD ["./api"]