Перенести решение лабораторной 1 как основу для лабораторной 2

This commit is contained in:
2026-10-06 11:54:05 +03:00
parent 65003b6119
commit 5c3f2bfad0
54 changed files with 4472 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
# Build stage: compile a static binary with the exact toolchain pinned in go.mod.
FROM golang:1.27.1-alpine3.23@sha256:d9e2f2f07b10cc922da3e80e035c3058810b328d5aef82d2c63680967c5e2ec9 AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN CGO_ENABLED=0 GOFLAGS=-mod=readonly go build -trimpath -ldflags="-s -w" -o /out/server ./cmd/server
# Runtime stage: minimal image, unprivileged user, the server is PID 1.
FROM alpine:3.23@sha256:fd791d74b68913cbb027c6546007b3f0d3bc45125f797758156952bc2d6daf40
RUN adduser -D -H -u 10001 app
COPY --from=build /out/server /usr/local/bin/server
USER app
ENV APP_HOST=0.0.0.0 \
APP_PORT=8080 \
APP_ENV=lab
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=2s --start-period=3s --retries=3 \
CMD wget -qO- "http://127.0.0.1:${APP_PORT:-8080}/health/ready" >/dev/null || exit 1
ENTRYPOINT ["/usr/local/bin/server"]