From 1ab51fa57812958e5f49df885fdec9beccc9bb59 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Wed, 17 Feb 2021 22:19:42 +0100 Subject: [PATCH] Move docker to top level, include frontend --- .gitignore | 1 + api/Dockerfile | 10 ++++---- api/docker-compose.yaml | 35 -------------------------- docker-compose.yaml | 54 +++++++++++++++++++++++++++++++++++++++++ frontend/Dockerfile | 9 +++++++ frontend/package.json | 5 ++-- 6 files changed, 71 insertions(+), 43 deletions(-) create mode 100644 .gitignore delete mode 100644 api/docker-compose.yaml create mode 100644 docker-compose.yaml create mode 100644 frontend/Dockerfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4083037 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +local diff --git a/api/Dockerfile b/api/Dockerfile index c6d0ffa..1fa6439 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,11 +1,11 @@ FROM node:14 -WORKDIR /opt/obsAPI -ADD package.json package-lock.json /opt/obsAPI/ +WORKDIR /opt/obs/api +ADD package.json package-lock.json /opt/obs/api/ RUN npm ci -ADD src /opt/obsAPI/src/ +ADD src /opt/obs/api/src/ -EXPOSE 8080 -ENV PORT=8080 +EXPOSE 3000 +ENV PORT=3000 CMD ["npm", "start"] diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml deleted file mode 100644 index 5996af5..0000000 --- a/api/docker-compose.yaml +++ /dev/null @@ -1,35 +0,0 @@ -version: '3' - -services: - mongo: - image: mongo - tty: true - volumes: - - ./local/mongo:/data/db - ports: - - '27017:27017' - restart: on-failure - - api: - image: obs-api - build: - context: . - dockerfile: ./Dockerfile - volumes: - - ./src:/opt/obsAPI/src - - ./local/api-data:/data - - .migrations.js:/opt/obsAPI/.migrations.js - - ./migrations:/opt/obsAPI/migrations/ - environment: - - PORT=3000 - - MONGODB_URL=mongodb://mongo/obsTest - - DATA_DIR=/data - links: - - mongo - ports: - - '3000:3000' - restart: on-failure - command: - - npm - - run - - dev diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..f6ab96e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,54 @@ +version: '3' + +services: + mongo: + image: mongo + tty: true + volumes: + - ./local/mongo:/data/db + ports: + - '27017:27017' + restart: on-failure + + api: + image: obs-api + build: + context: ./api + volumes: + - ./api/src:/opt/obs/api/src + - ./local/api-data:/data + - ./api/.migrations.js:/opt/obs/api/.migrations.js + - ./api/migrations:/opt/obs/api/migrations/ + environment: + - PORT=3000 + - MONGODB_URL=mongodb://mongo/obsTest + - DATA_DIR=/data + links: + - mongo + ports: + - '3000:3000' + restart: on-failure + command: + - npm + - run + - dev + + frontend: + image: obs-frontend + build: + context: ./frontend + volumes: + - ./frontend/src:/opt/obs/frontend/src + - ./frontend/public:/opt/obs/frontend/public + - ./frontend/tsconfig.json:/opt/obs/frontend/tsconfig.json + - ./frontend/package.json:/opt/obs/frontend/package.json + environment: + - PORT=3000 + links: + - api + ports: + - '3001:3000' + restart: on-failure + command: + - npm + - start diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..58b9016 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,9 @@ +FROM node:14 + +WORKDIR /opt/obs/frontend +ADD package.json package-lock.json /opt/obs/frontend/ +RUN npm ci + +ADD tsconfig.json /opt/obs/frontend +ADD public/ /opt/obs/frontend/public/ +ADD src/ /opt/obs/frontend/src/ diff --git a/frontend/package.json b/frontend/package.json index 33cbf33..2e60073 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -30,7 +30,7 @@ "web-vitals": "^0.2.4" }, "scripts": { - "start": "PORT=3001 react-scripts start", + "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" @@ -53,8 +53,7 @@ "last 1 safari version" ] }, - "proxy": "http://localhost:3000", - "port": 3001, + "proxy": "http://api:3000", "devDependencies": { "@types/lodash": "^4.14.168", "@types/react-redux": "^7.1.16",