Files
im_webapp/Dockerfile
T
Your Name df173879fa
Deploy im-webapp production / deploy (push) Successful in 1m35s
fix: route IM clients through current origin
2026-10-19 17:23:34 +08:00

44 lines
1.5 KiB
Docker

# ---- Stage 1: build static assets ----
# The active frontend lives under web/ (Vite + React + TypeScript). The legacy
# root-level Webpack application has been removed; production must only build web/.
FROM node:22-alpine AS build
WORKDIR /app/web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web/. .
# VITE_TINODE_API_KEY is read by src/lib/config.ts (import.meta.env.VITE_TINODE_API_KEY) at build
# time -- Vite only exposes env vars prefixed VITE_ to client code, so the ARG is renamed on its
# way into the build's environment rather than passed through under its old webpack-era name.
ARG TINODE_API_KEY=
ENV VITE_TINODE_API_KEY=$TINODE_API_KEY
# The production web UI and IM REST API use different origins. Local development leaves this unset
# and continues to use Vite's same-origin /v1/im proxy.
ARG TINODE_API_BASE=
ENV VITE_TINODE_API_BASE=$TINODE_API_BASE
# Leave the file origin unset in production so downloads use the current site's /v0/file route.
# A build-time override remains available for isolated development deployments.
ARG TINODE_FILE_BASE=
ENV VITE_TINODE_FILE_BASE=$TINODE_FILE_BASE
RUN npm run build
# ---- Stage 2: serve with nginx ----
FROM nginx:alpine
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html
# Vite's build output is fully self-contained: index.html, public assets and
# content-hashed JS/CSS chunks.
COPY --from=build /app/web/dist/. ./
HEALTHCHECK --interval=1m --timeout=3s --start-period=10s \
CMD wget -q -O /dev/null http://localhost/ || exit 1
EXPOSE 80