From 23f939c16a7fd12856d243031bf77fd8a6522cfe Mon Sep 17 00:00:00 2001 From: DTieman Date: Mon, 20 Mar 2023 19:58:28 +0100 Subject: [PATCH 1/3] first attempt --- .dockerignore | 3 +++ Dockerfile | 15 +++++++++++++++ docker-compose.yml | 15 +++++++++++++++ nginx/nginx.conf | 21 +++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 nginx/nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6f692d5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.env.example +.idea +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf56234 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# Create a production build of the app +FROM node:16.9.1 as build +WORKDIR /app +ENV PATH /app/node_modules/.bin:$PATH +COPY package.json ./ +RUN npm install +COPY . . +RUN npm run build + +FROM nginx:stable +COPY --from=build /app/build /usr/share/nginx/html +RUN rm /etc/nginx/conf.d/default.conf +COPY nginx/nginx.conf /etc/nginx/conf.d +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ee90c9d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.9' +services: + server: + build: + context: . + dockerfile: Dockerfile + #target: final + container_name: 'MauMau-Client' + restart: always + networks: + - MauMau +networks: + MauMau: + # hier later extern naar client + driver: bridge \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..60ee47c --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,21 @@ +server { + + listen 80; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + + # to redirect all the requests to index.html, + # useful when you are using react-router + + try_files $uri /index.html; + } + + error_page 500 502 503 504 /50x.html; + + location = /50x.html { + root /usr/share/nginx/html; + } + +} \ No newline at end of file From 8e9e5e1b0168b35b50444d345fb264e0ef37c9f1 Mon Sep 17 00:00:00 2001 From: DTieman Date: Tue, 21 Mar 2023 17:21:37 +0100 Subject: [PATCH 2/3] bye nginx --- Dockerfile | 17 ++++++----------- nginx/nginx.conf | 21 --------------------- 2 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 nginx/nginx.conf diff --git a/Dockerfile b/Dockerfile index cf56234..86a0913 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,10 @@ # Create a production build of the app FROM node:16.9.1 as build -WORKDIR /app -ENV PATH /app/node_modules/.bin:$PATH -COPY package.json ./ -RUN npm install COPY . . -RUN npm run build +RUN npm install --silent -FROM nginx:stable -COPY --from=build /app/build /usr/share/nginx/html -RUN rm /etc/nginx/conf.d/default.conf -COPY nginx/nginx.conf /etc/nginx/conf.d -EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +RUN npm run build +RUN npm install -g serve + +EXPOSE 3000 +CMD serve -l 3000 -s build \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf deleted file mode 100644 index 60ee47c..0000000 --- a/nginx/nginx.conf +++ /dev/null @@ -1,21 +0,0 @@ -server { - - listen 80; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - - # to redirect all the requests to index.html, - # useful when you are using react-router - - try_files $uri /index.html; - } - - error_page 500 502 503 504 /50x.html; - - location = /50x.html { - root /usr/share/nginx/html; - } - -} \ No newline at end of file From f9ac888da8a6e185a4ee1d5c6d464c73d1ca9d02 Mon Sep 17 00:00:00 2001 From: Jordan Geurtsen Date: Wed, 22 Mar 2023 10:07:15 +0100 Subject: [PATCH 3/3] fixed docker --- .env | 1 + .env.production | 1 + Dockerfile | 3 ++- docker-compose.yml | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .env create mode 100644 .env.production diff --git a/.env b/.env new file mode 100644 index 0000000..4452883 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +REACT_APP_API_URL= \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..ed36bc0 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +REACT_APP_API_URL="localhost:80" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 86a0913..52d0252 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ # Create a production build of the app FROM node:16.9.1 as build COPY . . -RUN npm install --silent +COPY .env.development .env +RUN npm install --silent RUN npm run build RUN npm install -g serve diff --git a/docker-compose.yml b/docker-compose.yml index ee90c9d..1267d11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: dockerfile: Dockerfile #target: final container_name: 'MauMau-Client' + ports: + - '3000:3000' restart: always networks: - MauMau