From fd783905400bca3b062d4ab745131928c0af4bf9 Mon Sep 17 00:00:00 2001 From: leej3 Date: Fri, 20 Sep 2024 13:40:58 +0100 Subject: [PATCH 1/2] update compose set up --- .docker/backend.dockerfile | 6 +++++ .docker/frontend.dockerfile | 6 +++++ .dockerignore | 3 +++ docker-compose.test.yml | 35 ++++++++++++++++++------- docker-compose.yml | 52 +++++++++++++++++++++---------------- 5 files changed, 69 insertions(+), 33 deletions(-) create mode 100644 .docker/backend.dockerfile create mode 100644 .docker/frontend.dockerfile create mode 100644 .dockerignore diff --git a/.docker/backend.dockerfile b/.docker/backend.dockerfile new file mode 100644 index 000000000..50b9e9401 --- /dev/null +++ b/.docker/backend.dockerfile @@ -0,0 +1,6 @@ +FROM node:17 +EXPOSE 3000 +COPY . /gitpay +WORKDIR /gitpay +RUN npm install +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/.docker/frontend.dockerfile b/.docker/frontend.dockerfile new file mode 100644 index 000000000..20db61241 --- /dev/null +++ b/.docker/frontend.dockerfile @@ -0,0 +1,6 @@ +FROM node:17.3.0 +EXPOSE 8082 +COPY ./frontend /gitpay/frontend +WORKDIR /gitpay/frontend +RUN npm install +CMD ["npm", "run", "dev"] diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..97ab348a9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +**/node_modules + +.* \ No newline at end of file diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 0b9eb1918..641b8c248 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -1,18 +1,33 @@ -version: '3.7' - services: backend_test: - image: node:8.6 - command: sh -c "npm install && npm run migrate-test && npm run test" - working_dir: /gitpay - volumes: - - .:/gitpay + container_name: backend_test + image: backend + command: bash -c "npm run migrate-test && npm run seed-test && npm run test" + build: + context: . + dockerfile: .docker/backend.dockerfile environment: - NODE_ENV=test - network_mode: host + - POSTGRES_PORT=5433 + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=gitpay_test + - OAUTH_CLIENT_ID=fakeid + - OAUTH_CLIENT_SECRET=fakesecret + - PAYPAL_HOST="https://api.sandbox.paypal.com" + + pull_policy: missing + depends_on: + - db_test + restart: "no" + ports: + - "3001:3000" + db_test: + container_name: db_test image: postgres - environment: + pull_policy: missing + ports: + - "5433:5432" + environment: - POSTGRES_PASSWORD=postgres - POSTGRES_DB=gitpay_test - network_mode: host \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 984b30710..d8dd165f5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,30 +1,36 @@ -version: '3.7' - services: - frontend: - image: node:8.6 - command: sh -c "npm install && npm run dev" - working_dir: /gitpay/frontend - volumes: - - .:/gitpay - network_mode: host + db: + container_name: db + env_file: + - .env + image: postgres + pull_policy: missing ports: - - "8082:8082" - expose: - - "8082" + - "5432:5432" + backend: + container_name: backend + image: backend env_file: - .env - image: node:8.6 - command: sh -c "npm install && npm run migrate && npm run start" - working_dir: /gitpay - volumes: - - .:/gitpay - network_mode: host + command: bash -c 'npm run migrate && npm run seed && npm run start' + build: + context: . + dockerfile: .docker/backend.dockerfile + pull_policy: missing ports: - "3000:3000" - db: - env_file: - - .env - image: postgres - network_mode: host + restart: always + depends_on: + - db + + frontend: + container_name: frontend + build: + context: . + dockerfile: .docker/frontend.dockerfile + pull_policy: missing + ports: + - "8082:8082" + depends_on: + - backend From cde38a2575a082da04274b16c5a3bbaf4129fc62 Mon Sep 17 00:00:00 2001 From: leej3 Date: Fri, 20 Sep 2024 13:42:41 +0100 Subject: [PATCH 2/2] add potential config modification --- config/config.json | 6 +++--- config/secrets.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/config.json b/config/config.json index fe1a85305..461a63afd 100644 --- a/config/config.json +++ b/config/config.json @@ -3,7 +3,7 @@ "username": "postgres", "password": "postgres", "database": "gitpay_dev", - "host": "127.0.0.1", + "host": "db", "port": 5432, "dialect": "postgres", "logging": false, @@ -13,8 +13,8 @@ "username": "postgres", "password": "postgres", "database": "gitpay_test", - "host": "127.0.0.1", - "port": 5432, + "host": "db_test", + "port": 5433, "dialect": "postgres", "logging": false } diff --git a/config/secrets.js b/config/secrets.js index 34771c82c..1a50bed69 100644 --- a/config/secrets.js +++ b/config/secrets.js @@ -6,7 +6,7 @@ const databaseDev = { username: 'postgres', password: 'postgres', database: 'gitpay_dev', - host: '127.0.0.1', + host: 'db', port: 5432, dialect: 'postgres', logging: false @@ -16,8 +16,8 @@ const databaseTest = { username: 'postgres', password: 'postgres', database: 'gitpay_test', - host: '127.0.0.1', - port: 5432, + host: 'db_test', + port: 5433, dialect: 'postgres', logging: false } @@ -27,7 +27,7 @@ const databaseProd = { password: null, database: process.env.DATABASE_URL, schema: 'public', - host: '127.0.0.1', + host: 'db', port: 5432, dialect: 'postgres', protocol: 'postgres' @@ -38,7 +38,7 @@ const databaseStaging = { password: null, database: process.env.DATABASE_URL, schema: 'public', - host: '127.0.0.1', + host: 'db', port: 5432, dialect: 'postgres', protocol: 'postgres'