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.sh
script is executable:chmod +x combine-env.sh
Clone this repository to your local machine:
git clone https://github.com/bsospace/SportSphere.git
cd sportsphere
Define 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.sh
The script will generate a root .env
file containing both frontend and backend environment variables. β
Run Docker Compose to start all services:
docker compose up
This will:
- π₯οΈ Build the frontend and backend Docker images.
- π οΈ Start the
frontend
,backend
,db
(PostgreSQL), andpgadmin
services.
- 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:
[email protected]
- Password:
securepassword
- Email:
To stop the application, press Ctrl + C
or run:
docker compose down
If you encounter warnings about missing .env
variables:
- Ensure the
.env
files exist in thefrontend
andbackend
directories. - Re-run the
combine-env.sh
script:./combine-env.sh
If changes are made to the Dockerfile
or dependencies, rebuild the services:
docker compose up --build
- The
combine-env.sh
script automatically combines variables fromfrontend/.env
andbackend/.env
into a root.env
file. π - This structure ensures modular development while keeping environment configuration consistent. β
Enjoy building your Sportsphere application! πβ½π