From 15565d5d37d4f4f2451571dbaaab94af86ddbfad Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Wed, 28 Feb 2024 16:29:40 +0330 Subject: [PATCH] add docker files --- .dockerignore | 11 ++++---- Dockerfile | 1 + docker-compose.dev.yml | 60 +++++++++++++++++++++++++++-------------- docker-compose.test.yml | 38 ++++++++++++++------------ 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/.dockerignore b/.dockerignore index 8930602f..6033c825 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,5 @@ -node_modules -logs -*.log -coverage -lib -.idea +.github/ +coverage/ +dist/ +node_modules/ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4e22a60c..69eabe5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM node:18-alpine AS base + WORKDIR /project COPY . . RUN npm ci diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index d856a336..8498d868 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,27 +1,47 @@ version: "3.9" services: + app: + build: + context: . + target: dev + dockerfile: Dockerfile + environment: + - NODE_ENV=test + - PORT=3000 + - DB_HOST=mongo + - DB_PORT=27017 + - DB_USER=root + - DB_PASSWORD=pass + - DB_NAME=RnDAO + - DISCORD_CLIENT_ID=1 + - DISCORD_CLIENT_SECRET=1 + - SENTRY_DSN=1 + - SENTRY_ENV=test + - DISCORD_BOT_TOKEN=1 + - REDIS_HOST=redis + - REDIS_PORT=6379 + - REDIS_PASSWORD= + - RABBIT_HOST=localhost + - RABBIT_PORT=5672 + - RABBIT_USER=root + - RABBIT_PASSWORD=pass + - LOG_LEVEL=info + - PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040 + volumes: + - ./coverage:/project/coverage + depends_on: + mongo: + condition: service_healthy mongo: - image: "mongo:6.0.8" - ports: - - 27017:27017 + image: "mongo:5.0.10" environment: + - MONGO_INITDB_DATABASE=RnDAO - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=pass - rabbitmq: - image: "rabbitmq:3-management-alpine" - ports: - - 5672:5672 - - 15672:15672 - environment: - - RABBITMQ_DEFAULT_USER=root - - RABBITMQ_DEFAULT_PASS=pass - neo4j: - image: "neo4j:5.9.0" - ports: - - 7687:7687 - - 7474:7474 - environment: - - NEO4J_AUTH=neo4j/password - - NEO4J_PLUGINS=["apoc", "graph-data-science"] - - NEO4J_dbms_security_procedures_unrestricted=apoc.*,gds.* + healthcheck: + test: echo 'db.stats().ok' | mongosh localhost:27017/test --quiet + interval: 60s + timeout: 10s + retries: 2 + start_period: 40s diff --git a/docker-compose.test.yml b/docker-compose.test.yml index f860e01d..64f31baf 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -7,14 +7,16 @@ services: target: test dockerfile: Dockerfile environment: + - NODE_ENV=test - PORT=3000 - DB_HOST=mongo - DB_PORT=27017 - DB_USER=root - DB_PASSWORD=pass - - DB_NAME=RnDAO-test + - DB_NAME=Core - REDIS_HOST=redis - REDIS_PORT=6379 + - REDIS_PASSWORD= - RABBIT_HOST=rabbitmq - RABBIT_PORT=5672 - RABBIT_USER=root @@ -25,22 +27,26 @@ services: - NEO4J_USER=neo4j - NEO4J_PASSWORD=password - NEO4J_DB=neo4j - - SENTRY_DSN=https://b9a3cf6fc9b849b6a9fdbd19dbb3a0eb@o4505110094282752.ingest.sentry.io/4505110103130112 - - SENTRY_ENV=test - - DISCORD_TRY_NOW_CALLBACK_URI=http://localhost:3000/api/v1/auth/try-now/callback - - DISCORD_LOGIN_CALLBACK_URI=http://localhost:3000/api/v1/auth/login/callback - - DISCORD_CONNECT_GUILD_CALLBACK_URI=http://localhost:3000/api/v1/guilds/connect/callback - - DISCROD_CLIENT_ID=1062450481529638963 - - DISCORD_CLIENT_SECRET=hTgn0dndAJz6oYhpxNGp3hc-ekxXp3Nj - - DISCORD_BOT_TOKEN=MTA2MjQ1MDQ4MTUyOTYzODk2Mw.GHhWYD.J4DhMWLAPy1lRV7YAB03YbVtjY6DFYk0UoipD8 - - JWT_SECRET=0%55e*enasdfm@@u7v9+amg-ju_d_ladsfasdf6(v*88h4$#h&o-i7a4%tv*hx + - SENTRY_DSN=empty + - SENTRY_ENV=empty + - DISCORD_AUTHORIZE_CALLBACK_URI=empty + - DISCORD_CONNECT_CALLBACK_URI=empty + - DISCORD_REQUEST_ACCESS_CALLBACK_URI=empty + - TWITTER_CONNECT_CALLBACK_URI=empty + - TWITTER_CLIENT_ID=empty + - TWITTER_CLIENT_SECRET=empty + - DISCROD_CLIENT_ID=empty + - DISCORD_CLIENT_SECRET=empty + - DISCORD_BOT_TOKEN=empty + - JWT_SECRET=0%55e*enmvbfm@@u7v9+amg-ju_d_safeasdf6(v*88h4$#h&o-i7ste#tv*hx - JWT_ACCESS_EXPIRATION_MINUTES=30 - JWT_REFRESH_EXPIRATION_DAYS=30 - JWT_DISCORD_REFRESH_EXPIRATION_DAY=30 - - FRONTEND_URL=https://localhost:3000/login - - NOTION_API_KEY=secret_INw8tqjWs80yXTOndXrpfp44HxLAvpMzGNkQ2XxkvqM - - NOTION_DATABASE_ID=948a3d77051f4f9b848319819d776709 - - BRIDGE_API_KEY=fa718429-8ac1-49a3-8715-7786cf9c09be + - FRONTEND_URL=empty + - NOTION_API_KEY=empty + - NOTION_DATABASE_ID=empty + - LOG_LEVEL=trace + - SESSION_SECRET=0%532345*edm@@u7v9+att-sdfed_l6(v*88h4$#h&o-i7awer3tv*yy volumes: - ./coverage:/project/coverage @@ -68,6 +74,7 @@ services: mongo: image: "mongo:6.0.8" environment: + - MONGO_INITDB_DATABASE=Core - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=pass healthcheck: @@ -106,6 +113,3 @@ services: networks: - api_application_network -networks: - api_application_network: - driver: bridge \ No newline at end of file