Fix Dockerization

This commit is contained in:
2025-07-15 14:09:42 +02:00
parent 2639a5301a
commit d9acd72d7b
13 changed files with 154 additions and 66 deletions

36
docker/Dockerfile Normal file
View File

@@ -0,0 +1,36 @@
# 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 --from=builder --chown=nginx:nginx /app/dist /usr/share/nginx/html
# Copy our custom nginx config
COPY nginx.conf /etc/nginx/nginx.conf
# Copy entrypoint script
COPY docker/entrypoint.sh /entrypoint.sh
# Make entrypoint executable
USER root
RUN chmod +x /entrypoint.sh
USER nginx
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]

13
docker/entrypoint.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
set -e
# Create runtime config file in writable location
cat > /runtime-config/config.js <<EOF
window.__APP_CONFIG__ = {
API_BASE_URL: "${API_BASE_URL}",
OTHER_VAR: "${OTHER_VAR}"
};
EOF
# Start Nginx
exec nginx -g "daemon off;"