From 96f35a2bcd510a7e4c4d82bae6a844387392e17f Mon Sep 17 00:00:00 2001 From: Murtadha Date: Thu, 11 Jul 2024 21:12:28 -0400 Subject: [PATCH] Setup nginx.conf and Dockerfile to build frontend application and run docker container --- Dockerfile | 12 ++++++++++++ nginx.conf | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3d34560 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:22 as build +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY --from=build /app/build /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 5137 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..64d4d10 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,14 @@ +server { + listen 5137; + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(?:jpg|jpeg|gif|png|ico|svg|woff|woff2|ttf|css|js)$ { + expires 30d; + add_header Cache-Control "public, no-transform"; + } +} \ No newline at end of file