diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 2bd986a..0852354 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -32,7 +32,7 @@ services: web: build: context: . - dockerfile: ./web/Dockerfile + dockerfile: ./web/Dockerfile.dev container_name: web env_file: .env networks: diff --git a/web/Dockerfile b/web/Dockerfile index a1b2d87..ff487cb 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,13 +1,23 @@ -FROM node:14.5.0-stretch-slim +FROM node:14.5.0-stretch-slim as build WORKDIR /app -COPY ./web/frontend ./ -RUN npm install +ENV PATH /app/node_modules/.bin:$PATH +COPY ./web/frontend/package.json ./ +COPY ./web/frontend/package-lock.json ./ + +RUN npm ci +RUN npm install react-scripts@3.4.1 -g + +COPY ./web/frontend ./ RUN npm run build + +FROM nginx:stable-alpine-slim +COPY --from=build /app/build /usr/share/nginx/html +COPY ./web/nginx/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 3000 -CMD ["npm", "start"] +CMD ["nginx", "-g", "daemon off;"] diff --git a/web/Dockerfile.dev b/web/Dockerfile.dev new file mode 100644 index 0000000..a1b2d87 --- /dev/null +++ b/web/Dockerfile.dev @@ -0,0 +1,13 @@ +FROM node:14.5.0-stretch-slim + + + +WORKDIR /app +COPY ./web/frontend ./ + +RUN npm install +RUN npm run build + +EXPOSE 3000 +CMD ["npm", "start"] + diff --git a/web/nginx/nginx.conf b/web/nginx/nginx.conf new file mode 100644 index 0000000..5b7d516 --- /dev/null +++ b/web/nginx/nginx.conf @@ -0,0 +1,17 @@ +server { + + listen 3000; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $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