forked from mtusi2026/mtusi2026lab4
44 lines
1.2 KiB
Docker
44 lines
1.2 KiB
Docker
FROM golang:1.26.5-alpine3.24 AS build
|
|
|
|
WORKDIR /src
|
|
ENV GOMAXPROCS=2 GOMEMLIMIT=1GiB
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN go build -p=1 -o /out/messenger ./cmd/messenger
|
|
RUN go build -p=1 -o /out/lab4experiment ./cmd/lab4experiment
|
|
|
|
FROM build AS test
|
|
|
|
CMD ["go", "test", "./internal/postgres", "./internal/session"]
|
|
|
|
FROM swaggerapi/swagger-ui:v5.31.2 AS swagger
|
|
|
|
COPY contracts/openapi.json /spec/openapi.json
|
|
ENV SWAGGER_JSON=/spec/openapi.json
|
|
|
|
FROM prom/prometheus:v3.13.3 AS prometheus
|
|
|
|
COPY monitoring/prometheus.yml /etc/prometheus/prometheus.yml
|
|
|
|
FROM grafana/grafana:13.1.6 AS grafana
|
|
|
|
COPY monitoring/grafana/provisioning /etc/grafana/provisioning
|
|
COPY monitoring/grafana/dashboards /etc/grafana/dashboards
|
|
|
|
FROM nginx:1.30.5-alpine AS loadbalancer
|
|
|
|
COPY nginx/nginx.conf /etc/nginx/nginx.conf
|
|
|
|
FROM alpine:3.24.2
|
|
|
|
RUN addgroup -S app && adduser -S -G app -u 10001 app
|
|
COPY --from=build --chown=app:app /out/messenger /app/messenger
|
|
COPY --from=build --chown=app:app /out/lab4experiment /app/lab4experiment
|
|
|
|
USER app
|
|
WORKDIR /app
|
|
HEALTHCHECK --interval=10s --timeout=2s --start-period=5s --retries=3 \
|
|
CMD wget -q -O /dev/null "http://127.0.0.1:${APP_PORT}/health/ready" || exit 1
|
|
CMD ["/app/messenger"]
|