Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions components/centraldashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ RUN npm ci \
&& npm run build \
&& npm prune --production

# Step 2: Packages assets for serving
FROM node:16.20.2-alpine AS serve

RUN apk add --no-cache tini
# Step 2: Serve static assets with nginx (smaller, secure)
FROM nginx:1.25-alpine AS serve

USER node

ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY --from=build --chown=node:node /centraldashboard .
# Copy built static assets from build stage
COPY --from=build --chown=nginx:nginx /centraldashboard/public /usr/share/nginx/html
COPY --from=build --chown=nginx:nginx /centraldashboard/app.bundle.js /centraldashboard/app.css /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8082
ENTRYPOINT ["/sbin/tini", "--" , "npm", "start"]

17 changes: 17 additions & 0 deletions components/centraldashboard/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
listen 8082;
server_name _;
root /usr/share/nginx/html;
index index.html;

# Cache static assets
location ~ \.(js|css|png|ico)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}

# SPA routing
location / {
try_files $uri $uri/ /index.html;
}
}
Loading