From 29d47ddd9b2d34451f650e611a128429e3f963bb Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Mon, 3 Nov 2025 21:05:21 +0100 Subject: [PATCH] refactor: update Dockerfiles and nginx configurations for consistency and optimization --- FrontendV2/Dockerfile | 6 +++--- FrontendV2/nginx.conf | 18 ++++++++++++++++++ admin/Dockerfile | 17 ++++++++++++----- admin/nginx.conf | 18 ++++++++++++++++++ admin/tsconfig.app.json | 2 +- docker-compose.yml | 9 ++------- 6 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 FrontendV2/nginx.conf create mode 100644 admin/nginx.conf diff --git a/FrontendV2/Dockerfile b/FrontendV2/Dockerfile index 4eb0346..6d0dfae 100644 --- a/FrontendV2/Dockerfile +++ b/FrontendV2/Dockerfile @@ -3,8 +3,7 @@ FROM node:18 as builder WORKDIR /app COPY package.json package-lock.json ./ - -RUN npm install --frozen-lockfile +RUN npm ci COPY . . RUN npm run build @@ -12,8 +11,9 @@ RUN npm run build FROM nginx:alpine AS runner WORKDIR /usr/share/nginx/html - COPY --from=builder /app/dist . +COPY nginx.conf /etc/nginx/conf.d/default.conf + EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/FrontendV2/nginx.conf b/FrontendV2/nginx.conf new file mode 100644 index 0000000..4aa4fa8 --- /dev/null +++ b/FrontendV2/nginx.conf @@ -0,0 +1,18 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { + expires 1y; + access_log off; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } +} \ No newline at end of file diff --git a/admin/Dockerfile b/admin/Dockerfile index 5e3a058..6d0dfae 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -1,12 +1,19 @@ -FROM node:20-alpine +FROM node:18 as builder WORKDIR /app -COPY package*.json ./ -RUN npm install +COPY package.json package-lock.json ./ +RUN npm ci COPY . . +RUN npm run build -EXPOSE 8003 +FROM nginx:alpine AS runner -CMD ["npm", "run", "dev"] \ No newline at end of file +WORKDIR /usr/share/nginx/html +COPY --from=builder /app/dist . + +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/admin/nginx.conf b/admin/nginx.conf new file mode 100644 index 0000000..4aa4fa8 --- /dev/null +++ b/admin/nginx.conf @@ -0,0 +1,18 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { + expires 1y; + access_log off; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } +} \ No newline at end of file diff --git a/admin/tsconfig.app.json b/admin/tsconfig.app.json index c433433..12d380b 100644 --- a/admin/tsconfig.app.json +++ b/admin/tsconfig.app.json @@ -30,7 +30,7 @@ }, "forceConsistentCasingInFileNames": true, - "ignoreDeprecations": "6.0" + "ignoreDeprecations": "5.0" }, "include": ["src"] } diff --git a/docker-compose.yml b/docker-compose.yml index 38ff213..14c77d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - # usr-frontendV2: + # usr-frontend_v2: # container_name: borrow_system-usr-frontend # build: ./FrontendV2 # ports: @@ -10,12 +10,7 @@ services: # container_name: borrow_system-admin-frontend # build: ./admin # ports: - # - "8003:8003" - # environment: - # - CHOKIDAR_USEPOLLING=true - # volumes: - # - ./admin:/app - # - /app/node_modules + # - "8003:80" # restart: unless-stopped backend: