Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 0s
- Remove hardcoded values from docker-compose.yml - Use environment variables from .env file instead - Update .env.example with placeholder values and instructions - Update DOCKER_README.md with .env file setup instructions - Fixes WebSocket origin check by allowing PHX_HOST to be configured per environment 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
3.5 KiB
3.5 KiB
RateMyClient - Docker Setup
This guide will help you run the RateMyClient Phoenix application using Docker Compose.
Prerequisites
- Docker Desktop installed and running
- Docker Compose (included with Docker Desktop)
Quick Start
-
Create your .env file:
cp .env.example .envThen edit
.envand update the values for your environment:- For production, generate a new
SECRET_KEY_BASE - Update
PHX_HOSTto your production domain (e.g.,ratemyclient.sivic.me)
- For production, generate a new
-
Build and start the containers:
docker-compose up --buildThis will:
- Build the Phoenix application Docker image
- Start PostgreSQL database
- Create the database
- Run migrations
- Create an admin user
- Start the Phoenix server
-
Access the application:
Open your browser and navigate to: http://localhost:4000
Default Admin Credentials
- Username:
admin - Password:
admin123 - Admin Login: http://localhost:4000/admin/login
Useful Commands
Start containers (detached mode)
docker-compose up -d
Stop containers
docker-compose down
View logs
docker-compose logs -f web
Rebuild after code changes
docker-compose up --build
Access the Phoenix console
docker-compose exec web bin/my_first_elixir_vibe_code remote
Run migrations manually
docker-compose exec web bin/my_first_elixir_vibe_code eval "MyFirstElixirVibeCode.Release.migrate()"
Access PostgreSQL
docker-compose exec db psql -U postgres -d my_first_elixir_vibe_code_dev
Volumes
The application uses a persistent volume for PostgreSQL data:
postgres_data: Stores database data
To completely reset the database:
docker-compose down -v
docker-compose up --build
Environment Variables
The application uses a .env file for configuration. Copy .env.example to .env and customize:
POSTGRES_USER: PostgreSQL username (default: postgres)POSTGRES_PASSWORD: PostgreSQL password (default: postgres)POSTGRES_DB: PostgreSQL database nameDATABASE_URL: PostgreSQL connection stringSECRET_KEY_BASE: Secret key for Phoenix (IMPORTANT: Generate a new one for production!)PHX_HOST: Hostname for the application (localhost for dev, your domain for production)PORT: Port to run the application on (default: 4000)
Generating a new SECRET_KEY_BASE
For production, you must generate a new secret key:
# Using Docker:
docker-compose run --rm web bin/my_first_elixir_vibe_code eval "IO.puts(:crypto.strong_rand_bytes(64) |> Base.encode64())"
# Or locally if you have Elixir installed:
mix phx.gen.secret
Troubleshooting
Port already in use
If port 4000 is already in use, change the port mapping in docker-compose.yml:
ports:
- "8080:4000" # Access via http://localhost:8080
Database connection issues
Make sure the database container is healthy:
docker-compose ps
Clean rebuild
docker-compose down -v
docker system prune -a
docker-compose up --build
Production Notes
This Docker setup is configured for production use. For actual production deployment:
- Change the
SECRET_KEY_BASEto a new secure value - Update database credentials in
docker-compose.yml - Consider using environment files (.env) instead of hardcoded values
- Set up SSL/TLS termination (nginx, traefik, etc.)
- Configure proper backup strategies for the database