This project manages a frontend and backend for the Sportsphere application using Docker Compose. Environment variables for the frontend and backend are stored separately and combined automatically before running the application.
.
├── docker-compose.yml # Docker Compose configuration
├── combine-env.sh # Script to combine .env files
├── frontend/ # Frontend code and environment
│ ├── Dockerfile
│ ├── .env
│ └── src/
├── backend/ # Backend code and environment
│ ├── Dockerfile
│ ├── .env
│ └── src/
└── .env (Generated automatically)
- Install Docker and ensure Docker Compose is included. 🐳
- Ensure the
combine-env.shscript is executable:chmod +x combine-env.sh
Clone this repository to your local machine:
git clone https://github.com/bsospace/SportSphere.git
cd sportsphereDefine environment variables in separate .env files for the frontend and backend:
NEXT_PUBLIC_APP_OPENID_API=
NEXT_PUBLIC_APP_URL_CALL_BACK=
NEXT_PUBLIC_API_URL=
NEXT_PUBLIC_URL=
NEXT_PUBLIC_API_SPORT=# Prisma Database Connection
DATABASE_URL=
# Application
APP_PORT=
NODE_ENV=
APP_URL=
# PostgreSQL Database
PG_USER=
PG_PASSWORD=
PG_DATABASE=
DB_PORT=
# PgAdmin
PGADMIN_EMAIL=
PGADMIN_PASSWORD=
PGADMIN_PORT=
# OpenID API
OPENID_API=
SERVICE_NAME=Run the combine-env.sh script to merge the .env files into a single .env file in the root directory:
./combine-env.shThe script will generate a root .env file containing both frontend and backend environment variables. ✅
Run Docker Compose to start all services:
docker compose upThis will:
- 🖥️ Build the frontend and backend Docker images.
- 🛠️ Start the
frontend,backend,db(PostgreSQL), andpgadminservices.
- Frontend: Visit http://localhost:5056 🖼️
- Backend: The backend API will run on http://localhost:3001 ⚙️
- pgAdmin: Visit http://localhost:5050 and log in using:
- Email:
admin@example.com - Password:
securepassword
- Email:
To stop the application, press Ctrl + C or run:
docker compose downIf you encounter warnings about missing .env variables:
- Ensure the
.envfiles exist in thefrontendandbackenddirectories. - Re-run the
combine-env.shscript:./combine-env.sh
If changes are made to the Dockerfile or dependencies, rebuild the services:
docker compose up --build- The
combine-env.shscript automatically combines variables fromfrontend/.envandbackend/.envinto a root.envfile. 🔗 - This structure ensures modular development while keeping environment configuration consistent. ✅
Enjoy building your Sportsphere application! 🏀⚽🏐