From f9f85423b4df710935340c9686e8334ec382aaab Mon Sep 17 00:00:00 2001 From: Juan Sebastian Montoya Date: Mon, 10 Mar 2025 23:26:10 -0500 Subject: [PATCH] chore: optimize web application Dockerfile and Nginx configuration --- apps/web/Dockerfile | 25 ++++++------------------- apps/web/nginx/default.conf | 9 +++++++++ 2 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 apps/web/nginx/default.conf diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index b104fba..62a8b13 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -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 \ No newline at end of file +# 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;"] diff --git a/apps/web/nginx/default.conf b/apps/web/nginx/default.conf new file mode 100644 index 0000000..7b7cb6c --- /dev/null +++ b/apps/web/nginx/default.conf @@ -0,0 +1,9 @@ +server { + listen 80; + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file