Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,69 @@ services:
- 3000:3000
env_file:
- /home/ubuntu-backend-shiksha2.0/.env


version: '3.8'

services:
postgres:
image: postgres:14
container_name: postgres
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"

pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
ports:
- "5050:80"
depends_on:
- postgres

keycloak:
image: quay.io/keycloak/keycloak:24.0.3
container_name: keycloak
command: start-dev
environment:
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB}
KC_DB_USERNAME: ${POSTGRES_USER}
KC_DB_PASSWORD: ${POSTGRES_PASSWORD}
KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN}
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
ports:
- "8080:8080"
depends_on:
- postgres

user-service:
build:
context: ./user-service
container_name: user-service
restart: always
ports:
- "3000:3000"
environment:
DB_HOST: postgres
DB_PORT: 5432
DB_USER: ${POSTGRES_USER}
DB_PASSWORD: ${POSTGRES_PASSWORD}
DB_NAME: ${POSTGRES_DB}
KEYCLOAK_URL: http://keycloak:8080
depends_on:
- postgres
- keycloak

volumes:
pgdata:
34 changes: 34 additions & 0 deletions example_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#server
POSTGRES_HOST="add-here"
POSTGRES_PORT="add-here"
POSTGRES_USERNAME="add-here"
POSTGRES_PASSWORD="add-here"
POSTGRES_DATABASE="add-here"
POSTGRES_SCHEMA="add-here"

#KEYCLOAK
KEYCLOAK="add-here"
KEYCLOAK_ADMIN="add-here"
KEYCLOAK_ADMIN="add-here"
Comment on lines +11 to +12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid Duplicate Environment Variable Declarations
The environment variable KEYCLOAK_ADMIN is declared twice (lines 11 and 12). This duplicate can lead to unexpected behavior. Please remove one of the entries to ensure only one value is defined.

KEYCLOAK_USER_TOKEN="add-here"
KEYCLOAK_REALM_RSA_PUBLIC_KEY="add-here"
KEYCLOAK_CLIENT_ID="add-here"
KEYCLOAK_REALM="add-here"
KEYCLOAK_CLIENT_SECRET="add-here"
KEYCLOAK_USERNAME="add-here"
KEYCLOAK_PASSWORD="add-here"
KEYCLOAK_ADMIN_TOKEN="add-here"

#Course Planner
AUTH_TOKEN="add-here"
INTERNAL_ACCESS_TOKEN="add-here"
#AWS
AWS_BUCKET_NAME = "add-here"
AWS_ACCESS_KEY_ID = "add-here"
AWS_SECRET_ACCESS_KEY= "add-here"
AWS_REGION = "add-here"

# sms for reset password and phone verification during signup
SMS_KEY="add-here"
OTP_EXPIRY="add-no-of-minutes"
OTP_DIGITS="add-no-of-digits"
34 changes: 34 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

echo "🚀 Starting Pratham Docker Setup..."

# Clone the user-service if not already cloned
if [ ! -d "user-service" ]; then
echo "📥 Cloning user-microservice..."
git clone git@github.com:tekdi/user-microservice.git user-service
fi

# Generate .env if not exists
if [ ! -f ".env" ]; then
echo "🔐 Creating .env file..."
cat <<EOT >> .env
POSTGRES_USER=prathamuser
POSTGRES_PASSWORD=prathampass
POSTGRES_DB=prathamdb
PGADMIN_EMAIL=admin@pratham.com
PGADMIN_PASSWORD=admin
KEYCLOAK_ADMIN=admin
KEYCLOAK_ADMIN_PASSWORD=admin
EOT
else
echo "✅ .env file already exists, skipping..."
fi

# Build and Start Containers
echo "🐳 Spinning up Docker containers..."
docker-compose up --build -d

echo "✅ All services are running:"
echo "- Node Service: http://localhost:3000"
echo "- PGAdmin: http://localhost:5050 (admin@pratham.com / admin)"
echo "- Keycloak: http://localhost:8080 (admin / admin)"