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! πβ½π