36 lines
807 B
Docker
36 lines
807 B
Docker
# Stage 1: Build application
|
|
FROM node:22-bookworm-slim AS builder
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Stage 2: Create runtime image
|
|
FROM nginxinc/nginx-unprivileged:1.25-alpine
|
|
|
|
# Create writable directories
|
|
USER root
|
|
RUN mkdir -p /runtime-config && \
|
|
chown nginx:nginx /runtime-config && \
|
|
chown -R nginx:nginx /var/cache/nginx && \
|
|
chown -R nginx:nginx /var/run
|
|
USER nginx
|
|
|
|
# Copy built assets
|
|
COPY --chown=nginx:nginx dist /usr/share/nginx/html
|
|
|
|
# Copy nginx config template
|
|
COPY --chown=nginx:nginx nginx.conf.template /etc/nginx/templates/
|
|
|
|
# Copy entrypoint script
|
|
COPY --chown=nginx:nginx docker/entrypoint.sh /entrypoint.sh
|
|
|
|
# Make entrypoint executable
|
|
USER root
|
|
RUN chmod +x /entrypoint.sh
|
|
USER nginx
|
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"] |