A Spring Boot-based online judge platform for problem solving.
- Docker (20.10+)
- Docker Compose (2.0+)
Before starting, create your environment file:
# Copy the example environment file
cp .env.example .env
# Edit .env with your preferred values (optional for development)
nano .envThe .env file contains sensitive configuration:
# Database credentials
POSTGRES_DB=cafeoj
POSTGRES_USER=cafeoj_user
POSTGRES_PASSWORD=your_secure_password
# Admin account password (created on first startup)
ADMIN_PASSWORD=your_admin_password
⚠️ Important: Never commit.envto version control. It's already in.gitignore.
# Start the application
docker compose up --build -d
# View logs
docker compose logs -f
# Stop the application
docker compose downWhen you run the Docker setup, the following components are created:
-
PostgreSQL Container (
cafeoj-postgres)- Database: configured via
POSTGRES_DB - User: configured via
POSTGRES_USER - Password: configured via
POSTGRES_PASSWORD - Port:
5432
- Database: configured via
-
Spring Boot Application Container (
cafeoj-app)- Port:
8080 - Profile:
docker - Admin user created with password from
ADMIN_PASSWORD
- Port:
-
Persistent Volume (
postgres-data)- Stores all database data
- Survives container restarts
-
Network (
cafeoj-network)- Allows containers to communicate
Once started, access the application at:
- Homepage: http://localhost:8080
docker compose up -d # Start in detached mode
docker compose up --build -d # Build and start
docker compose down # Stop services
docker compose down -v # Stop and remove volumes
docker compose logs -f # Follow logs
docker compose logs -f app # Follow app logs only
docker compose ps # Show status
docker compose restart # Restart services- Edit your code in the
srcdirectory - Rebuild and restart:
docker compose up --build -d
To access the PostgreSQL database directly:
docker exec -it cafeoj-postgres psql -U cafeoj_user -d cafeojCommon PostgreSQL commands:
\dt -- List tables
\d users -- Describe users table
SELECT * FROM users; -- Query users
\q -- QuitAll sensitive configuration is managed via the .env file. Available variables:
| Variable | Description | Default |
|---|---|---|
POSTGRES_DB |
Database name | cafeoj |
POSTGRES_USER |
Database username | cafeoj_user |
POSTGRES_PASSWORD |
Database password | (required) |
ADMIN_PASSWORD |
Admin account password | admin |
To customize:
# Create .env from template
cp .env.example .env
# Edit with your values
nano .envIf ports 8080 or 5432 are already in use, edit docker compose.yml:
services:
app:
ports:
- "8081:8080" # Change external port
postgres:
ports:
- "5433:5432" # Change external portCafeOJ/
├── docker compose.yml # Docker Compose configuration
├── Dockerfile # Application container definition
├── .dockerignore # Files to exclude from Docker build
├── .env.example # Environment variables template
├── README-DOCKER.md # Detailed Docker documentation
├── src/
│ └── main/
│ ├── java/ # Java source code
│ └── resources/
│ ├── application.properties # Default config
│ └── application-docker.properties # Docker config
└── pom.xml # Maven configuration
For production deployment:
- Change default passwords in your
.envfile (never use defaults in production) - Keep
.envsecret - it's gitignored and should never be committed - Use secrets management (Docker secrets, Kubernetes secrets, etc.) for production
- Enable HTTPS with proper SSL certificates
- Configure firewall rules
- Set up monitoring and alerting
- Implement backup strategy for the database
- Detailed Docker Documentation: https://docs.docker.com/
- Spring Boot Documentation: https://spring.io/projects/spring-boot
- PostgreSQL Documentation: https://www.postgresql.org/docs/
If you encounter issues:
- Check logs:
docker compose logs -f - Check container status:
docker compose ps - Try a clean restart:
docker compose down -vthendocker compose up --build -d
See LICENSE file for details.