Files
myoffice_public/Docker/Dockerfile.web
T

35 lines
1.2 KiB
Docker

# MyOffice SPA (nginx :80) — build from repo root:
# docker build -f Docker/Dockerfile.web --build-arg API_PUBLIC_URL=http://localhost:32081 -t myoffice-web .
FROM node:20-alpine AS build
WORKDIR /src
ARG API_PUBLIC_URL=http://localhost:32081
COPY MyOffice.SPA/package.json MyOffice.SPA/package-lock.json MyOffice.SPA/.npmrc ./
RUN npm ci
COPY MyOffice.SPA/ ./
# environment.ts is gitignored locally — stub + docker env with public API URL (host port).
RUN cp src/environments/environment.sample.ts src/environments/environment.ts \
&& printf '%s\n' \
'export const environment = {' \
' production: true,' \
" apiUrl: '${API_PUBLIC_URL}'," \
" identityServer: '${API_PUBLIC_URL}/'," \
" allowedUrls: ['${API_PUBLIC_URL}']," \
' requireHttps: false,' \
' externalLogins: {' \
" google: { clientId: '' }," \
" auth0: { clientId: '', domain: '' }" \
' }' \
'};' \
> src/environments/environment.docker.ts \
&& npm run build -- --configuration docker --output-path /out \
&& if [ -d /out/browser ]; then cp -a /out/browser/. /out/ && rm -rf /out/browser; fi
FROM nginx:1.27-alpine AS final
COPY Docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /out /usr/share/nginx/html
EXPOSE 80