Skip to content

Where Teams Unite, Matches Excite, and Scores Ignite! πŸ”₯

Notifications You must be signed in to change notification settings

bsospace/SportSphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€ Sportsphere Project πŸ†

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.


πŸ“‚ Folder Structure

.
β”œβ”€β”€ 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)

βœ… Prerequisites

  1. Install Docker and ensure Docker Compose is included. 🐳
  2. Ensure the combine-env.sh script is executable:
    chmod +x combine-env.sh

πŸš€ Steps to Run

1️⃣ Clone the Repository

Clone this repository to your local machine:

git clone https://github.com/bsospace/SportSphere.git
cd sportsphere

2️⃣ Add Environment Variables

Define environment variables in separate .env files for the frontend and backend:

frontend/.env

NEXT_PUBLIC_APP_OPENID_API=
NEXT_PUBLIC_APP_URL_CALL_BACK=
NEXT_PUBLIC_API_URL=
NEXT_PUBLIC_URL=
NEXT_PUBLIC_API_SPORT=

backend/.env

# 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=

3️⃣ Combine Environment Variables

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. βœ…

4️⃣ Start the Application

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), and pgadmin services.

5️⃣ Access the Application


πŸ›‘ Stopping the Application

To stop the application, press Ctrl + C or run:

docker compose down

πŸ”§ Troubleshooting

❗ Missing .env Variables

If you encounter warnings about missing .env variables:

  1. Ensure the .env files exist in the frontend and backend directories.
  2. Re-run the combine-env.sh script:
    ./combine-env.sh

πŸ”„ Rebuilding Images

If changes are made to the Dockerfile or dependencies, rebuild the services:

docker compose up --build

πŸ“Œ Additional Notes

  • The combine-env.sh script automatically combines variables from frontend/.env and backend/.env into a root .env file. πŸ”—
  • This structure ensures modular development while keeping environment configuration consistent. βœ…

Enjoy building your Sportsphere application! πŸ€βš½πŸ