27 lines
1.1 KiB
Docker
27 lines
1.1 KiB
Docker
FROM node:24.5.0-alpine3.22 AS web
|
|
WORKDIR /src/web
|
|
COPY web/package.json web/tsconfig.json web/index.html ./
|
|
COPY web/src ./src
|
|
RUN npm install --no-audit --no-fund && npm run build
|
|
|
|
FROM golang:1.24.5-alpine3.22 AS api
|
|
WORKDIR /src
|
|
COPY go.mod ./
|
|
COPY cmd ./cmd
|
|
RUN CGO_ENABLED=0 go test ./... && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /server ./cmd/server
|
|
|
|
FROM nginx:1.29.0-alpine3.22
|
|
RUN apk add --no-cache curl && rm -f /etc/nginx/conf.d/default.conf && \
|
|
sed -i 's#pid /run/nginx.pid;#pid /tmp/nginx.pid;#' /etc/nginx/nginx.conf && \
|
|
addgroup -S app && adduser -S -G app app && \
|
|
chown -R app:app /var/cache/nginx /var/run /var/log/nginx /etc/nginx/conf.d
|
|
COPY --from=web /src/web/dist /usr/share/nginx/html
|
|
COPY --from=api /server /usr/local/bin/server
|
|
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY deploy/entrypoint.sh /entrypoint.sh
|
|
RUN chmod 755 /entrypoint.sh
|
|
USER app
|
|
EXPOSE 8080
|
|
HEALTHCHECK --interval=20s --timeout=3s --start-period=5s --retries=3 CMD curl -fsS http://127.0.0.1:8080/healthz || exit 1
|
|
ENTRYPOINT ["/entrypoint.sh"]
|