chore: optimize web application Dockerfile and Nginx configuration
This commit is contained in:
parent
18582c1fdc
commit
f9f85423b4
2 changed files with 15 additions and 19 deletions
|
@ -23,22 +23,9 @@ ARG VITE_API_URL
|
||||||
ARG VITE_WS_URL
|
ARG VITE_WS_URL
|
||||||
RUN npx turbo run build --filter=web
|
RUN npx turbo run build --filter=web
|
||||||
|
|
||||||
# Production image, copy all the files and run the server
|
# Production image, copy the build files and run the server
|
||||||
FROM base AS runner
|
FROM nginx:1.27.1-alpine AS production
|
||||||
WORKDIR /app
|
COPY apps/web/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=builder /app/apps/web/dist /usr/share/nginx/html
|
||||||
ENV NODE_ENV production
|
EXPOSE 80
|
||||||
|
CMD ["nginx","-g","daemon off;"]
|
||||||
# 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
|
|
||||||
|
|
9
apps/web/nginx/default.conf
Normal file
9
apps/web/nginx/default.conf
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue