diff --git a/.dockerignore b/.dockerignore index ffc3acbf..cb81fd1b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,7 @@ * !app/ !frontend/ +!nginx/ !tests/ !tools/ !.coveragerc diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 7afa8dbb..59d481a3 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -5,7 +5,6 @@ services: build: context: . dockerfile: app/Dockerfile.prod - # command: ["/app/tools/run.sh"] volumes: - static_volume:/app/staticfiles environment: @@ -21,18 +20,14 @@ services: - network-backend - network-frontend - frontend: - build: ./frontend + nginx: + build: + context: . + dockerfile: nginx/Dockerfile environment: API_URL: "http://backend:8000" GOOGLE_TRACKING_ID: "" volumes: - - www:/app/dist - - nginx: - build: ./nginx - volumes: - - www:/var/www/html:ro - static_volume:/static ports: - 80:80 @@ -55,7 +50,6 @@ services: volumes: postgres_data: static_volume: - www: networks: network-backend: diff --git a/frontend/Dockerfile b/frontend/Dockerfile deleted file mode 100644 index e98b5674..00000000 --- a/frontend/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM node:13.7-alpine - -WORKDIR /app - -COPY . /app/ - -RUN apk add -U --no-cache git python3 make g++ \ - # && npm install -g yarn@latest \ - && yarn install \ - && yarn build \ - && apk del --no-cache git make g++ diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 66074cf6..c7389ed8 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,4 +1,16 @@ -FROM nginx:1.17.4-alpine +ARG NODE_VERSION="13.7" +FROM node:${NODE_VERSION}-alpine AS frontend-builder +COPY frontend/ /app/ +WORKDIR /app + +RUN apk add -U --no-cache git python3 make g++ \ + && yarn install \ + && yarn build \ + && apk del --no-cache git make g++ + +FROM nginx:1.17.4-alpine AS runtime + +COPY --from=frontend-builder /app/dist /var/www/html RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/conf.d +COPY nginx/nginx.conf /etc/nginx/conf.d