Files
Denozordec d69849e5e2
Publish telemt-api gateway Docker image / test (push) Successful in 23s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 1m54s
Refactor Docker setup to integrate Web UI and streamline configuration
- Updated Dockerfile to build and embed the SvelteKit Web UI directly into the gateway image, eliminating the need for a separate web service.
- Modified .dockerignore to exclude unnecessary directories related to the web service.
- Adjusted config.compose.yaml to remove CORS settings for the web service, as the UI now shares the same origin as the API.
- Enhanced README.md to reflect the new single-port architecture for accessing both the Web UI and API.
- Removed the standalone web Dockerfile and updated related documentation for local development and build processes.
2026-03-30 10:42:28 +07:00

36 lines
1.2 KiB
Docker

# syntax=docker/dockerfile:1
# --- Web UI (SvelteKit static) — тот же origin, что и API (порт шлюза)
FROM node:22-bookworm AS webui
WORKDIR /web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web/ ./
# Пустой URL: fetch идёт на тот же хост/порт, что и панель
ENV PUBLIC_TELEMT_GATEWAY_URL=
RUN npm run build
FROM golang:1.22-bookworm AS build
WORKDIR /src
COPY go.mod ./
COPY cmd/ ./cmd/
COPY internal/ ./internal/
COPY --from=webui /web/build/ ./internal/webui/static/
RUN go mod tidy && go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/gateway ./cmd/gateway
# Alpine: non-root + wget for HEALTHCHECK (distroless has no shell/wget).
FROM alpine:3.19
RUN apk add --no-cache ca-certificates wget \
&& addgroup -S gateway -g 65532 \
&& adduser -S -u 65532 -G gateway gateway \
&& mkdir -p /var/lib/telemt-gateway \
&& chown gateway:gateway /var/lib/telemt-gateway
COPY --from=build /out/gateway /gateway
USER gateway:gateway
EXPOSE 8080
ENV CONFIG_PATH=/etc/telemt-gateway/config.yaml
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q -O- http://127.0.0.1:8080/health >/dev/null || exit 1
ENTRYPOINT ["/gateway"]