From 5f9e9a71ee20c47ce924fded1bbe71cf0454f32d Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Sun, 8 Nov 2020 09:32:33 +0300 Subject: [PATCH] Add docker setup. --- .dockerignore | 4 ++++ Dockerfile | 34 ++++++++++++++++++++++++++++++++++ nginx.conf | 8 ++++++++ 3 files changed, 46 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5676584 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +# Created by .ignore support plugin (hsz.mobi) +.idea/ +dist/ +node_modules/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..550cbd0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +### STAGE 1: Build ### +# defining version of the base image +FROM node:15.1.0-alpine as build + +# defining work directory +WORKDIR /app + +# copying the json files into the image +COPY package*.json ./ + +RUN npm install + +# copying rest of project +COPY . . + +# running build script +RUN npm run build --prod + +### STAGE 2: Setup ### +# defining nginx image version +FROM nginx:1.19.4-alpine + +## Remove default nginx website +RUN rm -rf /usr/share/nginx/html/* + +# copy dist output from our first image +COPY --from=build /app/dist/cic-staff-client /usr/share/nginx/html + +# copy nginx configuration file +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 443 + +CMD [ "nginx", "-g", "daemon off;" ] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..1a12d7b --- /dev/null +++ b/nginx.conf @@ -0,0 +1,8 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } +}