From ccac02cc2ef657cfc41ea2fcc43b86890e6701a3 Mon Sep 17 00:00:00 2001 From: mhmdksh Date: Tue, 13 Aug 2024 12:57:13 +0300 Subject: [PATCH] Enhance Docker Setups for CI --- Dockerfile | 5 +- docker-compose-develop.yml | 47 ---------------- docker-compose-local-postgres-db-readonly.yml | 44 --------------- docker-compose-local-postgres-redis.yml | 55 ------------------- docker-compose-local.yml | 32 ----------- docker-compose-production.yml | 47 +++++----------- docker-compose-staging.yml | 47 ---------------- docker-compose.yml | 44 +++++++++++++++ 8 files changed, 61 insertions(+), 260 deletions(-) delete mode 100644 docker-compose-develop.yml delete mode 100644 docker-compose-local-postgres-db-readonly.yml delete mode 100644 docker-compose-local-postgres-redis.yml delete mode 100644 docker-compose-local.yml delete mode 100644 docker-compose-staging.yml create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index b2bda3482..5ef323411 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -#https://hub.docker.com/_/node?tab=tags&page=1 -FROM node:20.11.0-alpine3.18 +FROM node:20-alpine WORKDIR /usr/src/app @@ -22,4 +21,4 @@ COPY src ./src COPY test ./test COPY migration ./migration -RUN npm run build +RUN npm run build \ No newline at end of file diff --git a/docker-compose-develop.yml b/docker-compose-develop.yml deleted file mode 100644 index d73ad6371..000000000 --- a/docker-compose-develop.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: '3.3' - -services: - impact-graph: - #see https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref - - # is sometime you want to rollback you can change the tag manually in server( not commit to git) - # from master to your desired commit hash and the run command: - # 1. docker-compose -f docker-compose-develop.yml pull - # 2. docker-compose -f docker-compose-develop.yml down - # 3. docker-compose -f docker-compose-develop.yml up -d - image: ghcr.io/giveth/impact-graph:develop - command: npm run start:docker:server - environment: - - ENVIRONMENT=develop - - LOG_PATH=/usr/src/app/logs/impact-graph.log - restart: always - volumes: - # You should have a production.env file in the config folder - # We should bind config in two path, I think because running migrations(ts) needs one and running - # application(js) read from another path, if we change migrations two run them as js files then we need just on binding - - type: bind - source: ./config - target: /usr/src/app/config - - type: bind - source: ./config - target: /usr/src/app/build/config - - type: bind - source: ./logs - target: /usr/src/app/logs - ports: - - "4000:4000" - depends_on: - - redis-giveth - - redis-giveth: - # it's better to not using latest tag, maybe latest tag have some breaking changes - image: bitnami/redis:5.0.9-debian-10-r142 - container_name: redis-giveth - environment: - - ALLOW_EMPTY_PASSWORD=yes - restart: always - volumes: - - redis-data:/bitnami/redis/data - -volumes: - redis-data: diff --git a/docker-compose-local-postgres-db-readonly.yml b/docker-compose-local-postgres-db-readonly.yml deleted file mode 100644 index 3e56f8800..000000000 --- a/docker-compose-local-postgres-db-readonly.yml +++ /dev/null @@ -1,44 +0,0 @@ -services: - impact-graph-postgres: - # Use this postgres image https://github.com/Giveth/postgres-givethio - image: ghcr.io/giveth/postgres-givethio:latest - restart: always - environment: - - POSTGRES_DB=givethio - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - PGDATA=/var/lib/postgresql/data/pgdata - ports: - - "5432:5432" - volumes: - - db-data:/var/lib/postgresql/data - - impact-graph-postgres-replica: - # Read-only replica of the main Postgres container - image: ghcr.io/giveth/postgres-givethio:latest - restart: always - environment: - - POSTGRES_DB=givethio - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - PGDATA=/var/lib/postgresql/data/pgdata - - POSTGRES_PRIMARY_HOST=impact-graph-postgres - - POSTGRES_PRIMARY_PORT=5432 - - POSTGRES_PRIMARY_USER=postgres - - POSTGRES_PRIMARY_PASSWORD=postgres - - POSTGRES_REPLICA=true - ports: - - "5431:5432" - volumes: - - db-data-replica:/var/lib/postgresql/data - networks: - - giveth - - -volumes: - db-data: - db-data-replica: - - -networks: - giveth: \ No newline at end of file diff --git a/docker-compose-local-postgres-redis.yml b/docker-compose-local-postgres-redis.yml deleted file mode 100644 index d89a97187..000000000 --- a/docker-compose-local-postgres-redis.yml +++ /dev/null @@ -1,55 +0,0 @@ -version: '3.3' - -services: - impact-graph-postgres: - # Use this postgres image https://github.com/Giveth/postgres-givethio - image: ghcr.io/giveth/postgres-givethio:latest - restart: always - environment: - - POSTGRES_DB=givethio - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - PGDATA=/var/lib/postgresql/data/pgdata - ports: - - "5442:5432" - volumes: - - db-data:/var/lib/postgresql/data - - impact-graph-postgres-test: - # CAUTION: Running tests will delete all records of this db, so just use this container for test - # For running application use above container port: 5442 - - # Use this postgres image https://github.com/Giveth/postgres-givethio - image: ghcr.io/giveth/postgres-givethio:latest - restart: always - environment: - - POSTGRES_DB=givethio - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - PGDATA=/var/lib/postgresql/data/pgdata - ports: - - "5443:5432" - volumes: - - db-data-test:/var/lib/postgresql/data - - redis-giveth: - # it's better to not using the latest tag, maybe latest tag have some breaking changes - image: redis:7.2.0-alpine3.18 - container_name: redis-giveth - environment: - - REDIS_ALLOW_EMPTY_PASSWORD=yes - restart: always - ports: - - "6379:6379" - volumes: - - redis-data:/data - -volumes: - db-data: - db-data-test: - redis-data: - -networks: - giveth: - external: true - diff --git a/docker-compose-local.yml b/docker-compose-local.yml deleted file mode 100644 index 88c9da7be..000000000 --- a/docker-compose-local.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: '3.3' - -# This docker-compose is just for testing dockerfile locally but if you want to work on something -# I suggest you just use "npm start" and run application outside of docker, beucase this will not support watching changes -services: - impact-graph: - build: - context: . - command: npm run start:docker:locally - environment: - - ENVIRONMENT=local - - LOG_PATH=/usr/src/app/logs/impact-graph.log - restart: always - volumes: - # You should have a production.env file in the config folder - # We should bind config in two path, I think because running migrations(ts) needs one and running - # application(js) read from another path, if we change migrations two run them as js files then we need just on binding - - type: bind - source: ./config - target: /usr/src/app/config - - type: bind - source: ./config - target: /usr/src/app/build/config - - type: bind - source: ./logs - target: /usr/src/app/logs - ports: - - "4001:4000" - -networks: - giveth: - external: true diff --git a/docker-compose-production.yml b/docker-compose-production.yml index 7b768d85d..0cee5b95a 100644 --- a/docker-compose-production.yml +++ b/docker-compose-production.yml @@ -1,47 +1,30 @@ -version: '3.3' - services: - impact-graph: - #see https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref - - # is sometime you want to rollback you can change the tag manually in server( not commit to git) - # from master to your desired commit hash and the run command: - # 1. docker-compose -f docker-compose-production.yml pull - # 2. docker-compose -f docker-compose-production.yml down - # 3. docker-compose -f docker-compose-production.yml up -d - image: ghcr.io/giveth/impact-graph:latest + qacc-be: + container_name: qacc-be + build: . command: npm run start:docker:server environment: - ENVIRONMENT=production - - LOG_PATH=/usr/src/app/logs/impact-graph.log + - LOG_PATH=/usr/src/app/logs/qacc.log restart: always volumes: - # You should have a production.env file in the config folder - # We should bind config in two path, I think because running migrations(ts) needs one and running - # application(js) read from another path, if we change migrations two run them as js files then we need just on binding - - type: bind - source: ./config - target: /usr/src/app/config - - type: bind - source: ./config - target: /usr/src/app/build/config - - type: bind - source: ./logs - target: /usr/src/app/logs + - ./config:/usr/src/app/config + - ./config:/usr/src/app/build/config + - ./logs:/usr/src/app/logs ports: - - "4000:4000" - depends_on: - - redis-giveth + - "4001:4000" - redis-giveth: - # it's better to not using the latest tag, maybe latest tag have some breaking changes - image: redis:7.2.0-alpine3.18 - container_name: redis-giveth + qacc-redis: + container_name: qacc-redis + image: redis:7-alpine environment: - REDIS_ALLOW_EMPTY_PASSWORD=yes restart: always volumes: - redis-data:/data + ports: + - "6379:6379" volumes: - redis-data: + db-data: + redis-data: \ No newline at end of file diff --git a/docker-compose-staging.yml b/docker-compose-staging.yml deleted file mode 100644 index 1296b9aef..000000000 --- a/docker-compose-staging.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: '3.3' - -services: - impact-graph: - #see https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref - - # is sometime you want to rollback you can change the tag manually in server( not commit to git) - # from master to your desired commit hash and the run command: - # 1. docker-compose -f docker-compose-staging.yml pull - # 2. docker-compose -f docker-compose-staging.yml down - # 3. docker-compose -f docker-compose-staging.yml up -d - image: ghcr.io/giveth/impact-graph:staging - command: npm run start:docker:server - environment: - - ENVIRONMENT=staging - - LOG_PATH=/usr/src/app/logs/impact-graph.log - restart: always - volumes: - # You should have a production.env file in the config folder - # We should bind config in two path, I think because running migrations(ts) needs one and running - # application(js) read from another path, if we change migrations two run them as js files then we need just on binding - - type: bind - source: ./config - target: /usr/src/app/config - - type: bind - source: ./config - target: /usr/src/app/build/config - - type: bind - source: ./logs - target: /usr/src/app/logs - ports: - - "4000:4000" - depends_on: - - redis-giveth - - redis-giveth: - # it's better to not using the latest tag, maybe latest tag have some breaking changes - image: redis:7.2.0-alpine3.18 - container_name: redis-giveth - environment: - - REDIS_ALLOW_EMPTY_PASSWORD=yes - restart: always - volumes: - - redis-data:/data - -volumes: - redis-data: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..a4e757ad2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,44 @@ +services: + qacc-be: + container_name: qacc-be + build: . + command: npm run start:docker:locally + environment: + - ENVIRONMENT=local + - LOG_PATH=/usr/src/app/logs/qacc.log + restart: always + volumes: + - ./config:/usr/src/app/config + - ./config:/usr/src/app/build/config + - ./logs:/usr/src/app/logs + ports: + - "4001:4000" + + qacc-postgres: + container_name: qacc-postgres + image: postgres:16 + restart: always + environment: + - POSTGRES_DB=qacc + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - PGDATA=/var/lib/postgresql/data/pgdata + volumes: + - db-data:/var/lib/postgresql/data + ports: + - "5432:5432" + + qacc-redis: + container_name: qacc-redis + image: redis:7-alpine + environment: + - REDIS_ALLOW_EMPTY_PASSWORD=yes + restart: always + volumes: + - redis-data:/data + ports: + - "6379:6379" + +volumes: + db-data: + redis-data: \ No newline at end of file