From ba1ddbfde3b66b9276453d42ce428633e686cb2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Sun, 18 Sep 2022 19:56:01 -0300 Subject: [PATCH] Add container files --- .config/nginx.conf | 15 +++++++++++++++ .containerignore | 7 +++++++ Containerfile | 27 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 .config/nginx.conf create mode 100644 .containerignore create mode 100644 Containerfile diff --git a/.config/nginx.conf b/.config/nginx.conf new file mode 100644 index 0000000..c463077 --- /dev/null +++ b/.config/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + server_name ifsalas.xyz; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..2d0fa70 --- /dev/null +++ b/.containerignore @@ -0,0 +1,7 @@ +Containerfile +.containerignore +.gitignore +README.md + +build +node_modules diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..db1a388 --- /dev/null +++ b/Containerfile @@ -0,0 +1,27 @@ +# ======= NODE ======= +FROM node:alpine as build + +# Working directory (this is where the application will be inside the container). +WORKDIR /app + +# Copy the app to the container +COPY . /app/ + +# Prepare the container for building react +RUN npm install +RUN npm run build + +# ======= NGINX ======= +FROM nginx:alpine + +# Setup certbot with letsencrypt +RUN apk add certbot certbot-nginx + +COPY --from=build /app/build /usr/share/nginx/html +RUN rm /etc/nginx/conf.d/default.conf +COPY .config/nginx.conf /etc/nginx/conf.d + +# Fire up nginx +EXPOSE 80 443 +CMD ["nginx","-g","daemon off;"] +