|
1 |
| -# Refactor Platform – Docker Quickstart |
| 1 | +# Refactor Platform: Docker Quickstart |
2 | 2 |
|
3 |
| -This project uses Docker & Docker Compose for local development. It deploys a PostgreSQL database, a Rust back-end, and a Next.js front-end (all pre-built images from GitHub Container Registry). |
| 3 | +*This project uses Docker & Docker Compose for local development. It deploys a PostgreSQL database, a Rust back-end, and a Next.js front-end (all pre-built images from GitHub Container Registry).* |
4 | 4 |
|
5 | 5 | ## Prerequisites
|
6 | 6 |
|
7 | 7 | - Docker (v20+)
|
8 | 8 | - Docker Compose (v1.29+)
|
9 |
| -- A configured .env file (see examples) |
| 9 | +- A configured .env file (see below) |
10 | 10 |
|
11 |
| -## Steps & Commands |
| 11 | +## Example .env File |
12 | 12 |
|
13 |
| -1. Clone the repository & set up the environment: |
| 13 | +Below is an example of a complete and correct .env file. Copy this content (or adjust values as needed) and save it as .env in the project root. |
14 | 14 |
|
15 | 15 | ```bash
|
16 |
| - git clone <repository-url> && cd <repository-directory> |
17 |
| - ``` |
18 |
| - |
19 |
| -## Copy the example .env file and adjust values as needed |
| 16 | +# ============================== |
| 17 | +# PostgreSQL Configuration |
| 18 | +# ============================== |
| 19 | +POSTGRES_USER=refactor # PostgreSQL username |
| 20 | +POSTGRES_PASSWORD=password # PostgreSQL password |
| 21 | +POSTGRES_DB=refactor # PostgreSQL database name |
| 22 | +POSTGRES_HOST=postgres # Hostname for the PostgreSQL container (set in docker-compose) |
| 23 | +POSTGRES_PORT=5432 # Internal PostgreSQL port |
| 24 | +POSTGRES_SCHEMA=refactor_platform # Database schema |
| 25 | +# DATABASE_URL used by the Rust back-end to connect to Postgres |
| 26 | +DATABASE_URL=postgres://refactor:password@postgres:5432/refactor |
| 27 | + |
| 28 | +# ============================== |
| 29 | +# Rust Back-end Configuration |
| 30 | +# ============================== |
| 31 | +BACKEND_CONTAINER_NAME=refactor-platform # Name for the Rust back-end container |
| 32 | +BACKEND_IMAGE_NAME=ghcr.io/refactor-group/refactor-platform-rs/<branch-name>:latest |
| 33 | + # Pre-built image for the Rust back-end from GHCR |
| 34 | +BACKEND_ENV=development # Environment (development/production) |
| 35 | +BACKEND_ALLOWED_ORIGINS=* # Allowed CORS origins |
| 36 | +BACKEND_LOG_FILTER_LEVEL=DEBUG # Logging level for the back-end |
| 37 | +BACKEND_PORT=4000 # Port on which the Rust back-end listens |
| 38 | +BACKEND_INTERFACE=0.0.0.0 # Interface for the Rust back-end |
| 39 | +BACKEND_SERVICE_PROTOCOL=http # Protocol (usually http) |
| 40 | +BACKEND_SERVICE_PORT=4000 # Derived service port |
| 41 | +BACKEND_SERVICE_HOST=localhost # Hostname used by the service |
| 42 | +BACKEND_API_VERSION=0.0.1 # API version |
| 43 | + |
| 44 | +# ============================== |
| 45 | +# Next.js Front-end Configuration |
| 46 | +# ============================== |
| 47 | +FRONTEND_IMAGE_NAME=ghcr.io/refactor-group/refactor-platform-fe/<branch-name>:latest |
| 48 | + # Pre-built image for the Next.js front-end from GHCR |
| 49 | +FRONTEND_CONTAINER_NAME=refactor-platform-frontend # Name for the front-end container |
| 50 | +FRONTEND_SERVICE_INTERFACE=0.0.0.0 # Interface for the front-end service |
| 51 | +FRONTEND_SERVICE_PORT=3000 # Port for the front-end service |
| 52 | + |
| 53 | +# ============================== |
| 54 | +# TipTap Service Configuration |
| 55 | +# ============================== |
| 56 | +TIPTAP_URL="https://ok01532m.collab.tiptap.cloud" # URL for the TipTap service |
| 57 | +TIPTAP_AUTH_KEY="6122462e59d7cc8c6146f4e3b5c93dfad28c8a219838df69b59ffcec4cdc0041" |
| 58 | + # Authentication key for TipTap |
| 59 | +TIPTAP_JWT_SIGNING_KEY="0f38cb0650a8fc262258ad415f25c52579bfc4095b222f486557d24c8fafaeb8" # JWT signing key for TipTap |
| 60 | +``` |
20 | 61 |
|
21 |
| - ```bash |
22 |
| - cp .env.example .env |
23 |
| - ``` |
| 62 | +## Steps & Commands |
24 | 63 |
|
25 |
| -2. Use Docker Compose to build and start services: |
26 |
| - docker-compose --env-file .env up --build |
| 64 | +1. **Clone the repository & set up the environment:** |
27 | 65 |
|
28 |
| - ## This starts PostgreSQL (local), the Rust back-end, and the Next.js front-end |
| 66 | + ```bash |
| 67 | + # Clone the repository and change into the project directory |
| 68 | + git clone <repository-url> && cd <repository-directory> |
| 69 | + |
| 70 | + # Copy the example .env file and adjust values as needed |
| 71 | + cp .env.example .env |
| 72 | + ``` |
29 | 73 |
|
30 |
| -3. Basic Management Commands: |
| 74 | +1. **Build and Start the Containers with Docker Compose:** |
31 | 75 |
|
32 |
| -```bash |
33 |
| - docker-compose ps # List running containers |
34 |
| - docker-compose logs -f # Follow logs; press Ctrl+C to exit |
35 |
| - docker-compose restart rust-app # Restart the Rust back-end service |
36 |
| - docker-compose down # Stop and remove all containers and networks |
37 |
| - docker-compose down -v # Also remove volumes for a fresh start |
38 |
| - docker-compose exec rust-app cargo check # Run a command inside the Rust back-end container |
39 |
| - docker-compose exec rust-app cargo run # Run the Rust back-end application |
| 76 | + ```bash |
| 77 | + docker-compose --env-file .env up --build |
| 78 | + # This command starts: |
| 79 | + # - PostgreSQL (local) |
| 80 | + # - Rust back-end |
| 81 | + # - Next.js front-end |
40 | 82 | ```
|
41 | 83 |
|
42 |
| -4. Direct Docker Commands (Optional): |
| 84 | +1. **Basic Management Commands:** |
43 | 85 |
|
44 |
| - <!-- Pull the Rust back-end image from GHCR (if not built locally) --> |
45 | 86 | ```bash
|
46 |
| - docker pull ghcr.io/refactor-group/refactor-platform-rs/your-tag:latest # Replace 'your-tag' accordingly |
| 87 | + docker-compose ps # List running containers |
| 88 | + docker-compose logs -f # Follow live logs (press Ctrl+C to exit) |
| 89 | + docker-compose restart rust-app # Restart the Rust back-end container |
| 90 | + docker-compose down # Stop and remove all containers and networks |
| 91 | + docker-compose down -v # Stop containers and remove volumes for a fresh start |
| 92 | + docker-compose exec rust-app cargo check # Run 'cargo check' inside the Rust back-end container |
| 93 | + docker-compose exec rust-app cargo run # Run the Rust back-end application |
| 94 | + docker-compose ps # List running containers |
| 95 | + docker-compose logs -f # Follow live logs (press Ctrl+C to exit) |
| 96 | + docker-compose restart rust-app # Restart the Rust back-end container |
| 97 | + docker-compose exec rust-app cargo check # Run 'cargo check' inside the Rust back-end container |
| 98 | + docker-compose exec rust-app cargo run # Run the Rust back-end application |
47 | 99 | ```
|
48 | 100 |
|
49 |
| - ## Run the Rust back-end image directly |
| 101 | +1. **Direct Docker Commands (Optional):** |
50 | 102 |
|
51 | 103 | ```bash
|
| 104 | + # Pull the Rust back-end image from GHCR (if not built locally) |
| 105 | + docker pull ghcr.io/refactor-group/refactor-platform-rs/your-tag:latest # Replace 'your-tag' as needed |
| 106 | + |
| 107 | + # Run the Rust back-end image directly |
52 | 108 | docker run -p 4000:4000 --env-file .env --name refactor-backend ghcr.io/refactor-group/refactor-platform-rs/your-tag:latest
|
53 | 109 | ```
|
54 |
| - |
55 |
| -4. **Debugging / Troubleshooting:** |
56 | 110 |
|
57 |
| - ```bash |
| 111 | + **Note:** *By default, Docker Compose uses locally cached images. The remote image is pulled only once unless you force a new pull using commands like `docker-compose pull` or by passing the `--no-cache` flag.* |
58 | 112 |
|
| 113 | +1. **Debugging & Troubleshooting:** |
| 114 | + |
| 115 | + ```bash |
| 116 | + docker-compose exec rust-app bash # Access a shell in the Rust back-end container |
| 117 | + docker-compose exec rust-app env # View environment variables in the Rust back-end container |
| 118 | + docker-compose exec postgres bash # Access a shell in the PostgreSQL container |
| 119 | + docker-compose exec postgres pg_isready -U $POSTGRES_USER -d $POSTGRES_DB |
| 120 | + # Verify PostgreSQL is ready |
59 | 121 | docker-compose exec rust-app bash # Access a shell in the Rust back-end container
|
60 | 122 | docker-compose exec rust-app env # Check environment variables inside the rust-app container
|
61 | 123 | docker-compose exec postgres bash # Access a shell in the PostgreSQL container for troubleshooting
|
62 | 124 | docker-compose exec postgres pg_isready -U $POSTGRES_USER -d $POSTGRES_DB # Verify PostgreSQL is ready
|
| 125 | + docker-compose exec rust-app cargo test # Run tests inside the Rust back-end container |
63 | 126 | ```
|
64 | 127 |
|
65 |
| -**Notes:** |
| 128 | +**Final Notes:** |
66 | 129 |
|
67 | 130 | - Ensure your `.env` file includes required variables such as `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB`, `DATABASE_URL`, `BACKEND_PORT`, `BACKEND_INTERFACE`, `BACKEND_ALLOWED_ORIGINS`, `BACKEND_LOG_FILTER_LEVEL`, etc.
|
68 |
| -- The nextjs-app service uses the pre-built image from GHCR (update the image name if necessary). |
69 |
| -- If using docker-compose, the `.env` file located in the project root is automatically loaded. |
70 |
| - |
71 |
| -*This guide provides all essential commands to safely work with the containers using Docker and Docker Compose.* |
| 131 | +- Docker Compose automatically loads the `.env` file located in the project root. |
| 132 | +- The pre-built images from GHCR for both the Rust back-end and the Next.js front-end are used by default. These remote images are only pulled if not already available locally, unless a pull is forced. |
| 133 | +- The commands above follow best practices and help ensure a reliable setup every time you run the project. |
0 commit comments