chore: optimize web application Dockerfile and Nginx configuration

This commit is contained in:
Juan Sebastián Montoya 2025-03-10 23:26:10 -05:00
parent 18582c1fdc
commit f9f85423b4
2 changed files with 15 additions and 19 deletions

View file

@ -23,22 +23,9 @@ ARG VITE_API_URL
ARG VITE_WS_URL
RUN npx turbo run build --filter=web
# Production image, copy all the files and run the server
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
# Copy necessary files
COPY --from=builder /app/apps/web/dist ./dist
COPY --from=builder /app/apps/web/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
# Install serve to run the application
RUN npm install -g serve
# Expose the port
EXPOSE 5173
# Start the server
CMD serve -s dist -l 5173
# Production image, copy the build files and run the server
FROM nginx:1.27.1-alpine AS production
COPY apps/web/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/apps/web/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx","-g","daemon off;"]

View file

@ -0,0 +1,9 @@
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}