-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathorders.Dockerfile
More file actions
34 lines (23 loc) · 1.11 KB
/
orders.Dockerfile
File metadata and controls
34 lines (23 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM golang:1.24-alpine AS builder
WORKDIR /build
# Копируем только go.mod и go.sum для лучшего кэширования слоёв
COPY ./go.mod ./go.sum ./
RUN go mod download
# Копируем исходники
COPY . .
# Собираем статически скомпилированный бинарник
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o orders cmd/orders/main.go
# Конечный образ намного меньше, используем scratch
FROM alpine:latest
# Добавляем ca-certificates для HTTPS и создаем непривилегированного пользователя
RUN apk --no-cache add ca-certificates && \
addgroup -S appgroup && adduser -S appuser -G appgroup
# Копируем бинарник из предыдущего этапа
COPY --from=builder /build/orders /app/orders
# Используем непривилегированного пользователя
USER appuser
WORKDIR /app
# Документируем порты
EXPOSE 8080
# Определяем точку входа
ENTRYPOINT ["/app/orders", "sync", "-d"]