From f528f6eaeab8e61784ea161dd97ca24372088e1d Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Fri, 21 Nov 2025 22:14:03 +0700 Subject: [PATCH] reactor the Dockerfile.frontend to locate in Docker folder --- docker/Dockerfile.frontend | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docker/Dockerfile.frontend diff --git a/docker/Dockerfile.frontend b/docker/Dockerfile.frontend new file mode 100644 index 0000000..07e0855 --- /dev/null +++ b/docker/Dockerfile.frontend @@ -0,0 +1,21 @@ +FROM node:20-alpine AS build +WORKDIR /app + +# Install dependencies +COPY application/package.json application/package-lock.json ./ +RUN npm ci + +# Copy source and build +COPY application/. . +RUN npm run build + +FROM nginx:1.27-alpine +RUN rm -rf /usr/share/nginx/html/* +COPY --from=build /app/dist /usr/share/nginx/html + +# SPA fallback + static asset caching +RUN printf 'server {\n listen 80;\n server_name _;\n root /usr/share/nginx/html;\n index index.html;\n location / { try_files $uri $uri/ /index.html; }\n location ~* \\.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ { expires 7d; add_header Cache-Control "public, max-age=604800, immutable"; try_files $uri =404; }\n}\n' > /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx","-g","daemon off;"] +