From 006092e171a8e7f72d1f57e7df974fa327050dda Mon Sep 17 00:00:00 2001 From: prayansh_chhablani Date: Mon, 23 Dec 2024 22:42:29 +0530 Subject: [PATCH] pwd variable fix, redi-stack-server fix --- .env.sample | 5 ++++- .github/workflows/pull-request.yml | 9 +++++++-- docker-compose.dev.yaml | 26 +++++++------------------- setup.ts | 11 +++++++++++ 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.env.sample b/.env.sample index fa6a0fabaa..073cf6b0c2 100644 --- a/.env.sample +++ b/.env.sample @@ -104,4 +104,7 @@ MINIO_DATA_DIR= # this environment variable is for setting the environment variable for Image Upload size -IMAGE_SIZE_LIMIT_KB=3000 \ No newline at end of file +IMAGE_SIZE_LIMIT_KB=3000 + +# This environment variable is for setting the working directory when Docker is used +PWD=. \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 40a9166aec..a72db56825 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -354,7 +354,7 @@ jobs: echo "Error: MongoDB failed to start within timeout" echo "Fetching MongoDB logs..." docker-compose -f docker-compose.dev.yaml logs mongodb - echo "Shutting down services..." + echo "Shutting down MongoDB..." docker-compose -f docker-compose.dev.yaml down -v exit 1 @@ -370,10 +370,15 @@ jobs: done if [ $timeout -eq 0 ]; then echo "Error: Redis failed to start within timeout" + echo "Fetching Redis logs..." docker-compose -f docker-compose.dev.yaml logs redis-stack-server + echo "Shutting down Redis..." docker-compose -f docker-compose.dev.yaml down -v exit 1 - fi + + else + echo "Redis is ready!" + fi # Wait for TALAWA API to be healthy timeout=60 diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 12907723b7..99086d1f9d 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -1,5 +1,3 @@ -version: "3.8" - services: mongodb: image: mongo:latest @@ -37,6 +35,9 @@ services: build: context: . dockerfile: Dockerfile.dev + container_name: talawa-api-dev + ports: + - "4000:4000" volumes: - .:/usr/src/app - /usr/src/app/node_modules @@ -45,30 +46,17 @@ services: - redis-stack-server - minio environment: - - MONGO_DB_URL=mongodb://mongodb:27017 + - MONGO_DB_URL=mongodb://mongodb:27017/talawa-api - REDIS_HOST=redis-stack-server - REDIS_PORT=6379 - - caddy: - image: caddy/caddy:2.2.1-alpine - container_name: caddy-service - restart: unless-stopped - ports: - - "80:80" - - "443:443" - volumes: - - ./Caddyfile:/etc/caddy/Caddyfile - - $PWD/site:/srv - - caddy_data:/data - - caddy_config:/config + networks: + - talawa-network volumes: mongodb-data: redis-data: - caddy_data: - caddy_config: minio-data: networks: talawa-network: - driver: bridge + driver: bridge \ No newline at end of file diff --git a/setup.ts b/setup.ts index bad4b347bd..4e1a689055 100644 --- a/setup.ts +++ b/setup.ts @@ -1015,6 +1015,14 @@ async function main(): Promise { const REDIS_PASSWORD = ""; const MINIO_ENDPOINT = "http://minio:9000"; + const { pwdVariable } = await inquirer.prompt({ + type: "input", + name: "pwdVariable", + message: + "Please enter the value for PWD (working directory for Docker setup):", + default: ".", + }); + const config = dotenv.parse(fs.readFileSync(".env")); config.MONGO_DB_URL = DB_URL; @@ -1022,18 +1030,21 @@ async function main(): Promise { config.REDIS_PORT = REDIS_PORT; config.REDIS_PASSWORD = REDIS_PASSWORD; config.MINIO_ENDPOINT = MINIO_ENDPOINT; + config.PWD = pwdVariable; process.env.MONGO_DB_URL = DB_URL; process.env.REDIS_HOST = REDIS_HOST; process.env.REDIS_PORT = REDIS_PORT; process.env.REDIS_PASSWORD = REDIS_PASSWORD; process.env.MINIO_ENDPOINT = MINIO_ENDPOINT; + process.env.PWD = pwdVariable; updateEnvVariable(config); console.log(`Your MongoDB URL is:\n${process.env.MONGO_DB_URL}`); console.log(`Your Redis host is:\n${process.env.REDIS_HOST}`); console.log(`Your Redis port is:\n${process.env.REDIS_PORT}`); console.log(`Your MinIO endpoint is:\n${process.env.MINIO_ENDPOINT}`); + console.log(`Your PWD value is:\n${process.env.PWD}`); } if (!isDockerInstallation) {