From 4c8b937c09f8ca50ab6805590f5025e7048d0b3b Mon Sep 17 00:00:00 2001 From: FrenchGithubUser Date: Mon, 1 Sep 2025 17:23:36 +0200 Subject: [PATCH] added redis setup in `compose.yml` and in the docs --- backend/storage/src/redis/error.rs | 2 +- compose.yml | 20 +++++++++++++++++--- docs/src/run-docker.md | 9 ++++++++- docs/src/run-standard.md | 10 ++++++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/backend/storage/src/redis/error.rs b/backend/storage/src/redis/error.rs index 222c7e24..4a2283b5 100644 --- a/backend/storage/src/redis/error.rs +++ b/backend/storage/src/redis/error.rs @@ -6,7 +6,7 @@ pub type Result = std::result::Result; pub enum RedisError { #[error("connection error")] ConnectionError(#[source] PoolError), - #[error("cmd execution error")] + #[error("cmd execution error: '{0}'")] CmdError(#[source] redis::RedisError), } diff --git a/compose.yml b/compose.yml index 26e2177a..fb61c484 100644 --- a/compose.yml +++ b/compose.yml @@ -20,7 +20,7 @@ services: - backend/.env.docker - backend/.env healthcheck: - test: [ "CMD-SHELL", "pg_isready -U arcadia" ] + test: ["CMD-SHELL", "pg_isready -U arcadia"] interval: 5s timeout: 5s retries: 5 @@ -40,6 +40,20 @@ services: depends_on: db: condition: service_healthy + + redis: + image: redis + container_name: arcadia_redis + restart: always + ports: + - 6379:6379 + volumes: + - redis_data:/data + env_file: + - backend/api/.env.docker + - backend/api/.env + command: redis-server --requirepass ${REDIS_PASSWORD} + backend: container_name: arcadia_api volumes: @@ -49,7 +63,7 @@ services: context: backend dockerfile: Dockerfile ports: - - '8080:8080' + - "8080:8080" env_file: - backend/api/.env.docker - backend/api/.env @@ -68,7 +82,6 @@ services: - .env - .env.docker - frontend: container_name: arcadia_frontend build: @@ -89,5 +102,6 @@ services: volumes: db_data: + redis_data: cargo-registry: cargo-target: diff --git a/docs/src/run-docker.md b/docs/src/run-docker.md index 4685faec..86739966 100644 --- a/docs/src/run-docker.md +++ b/docs/src/run-docker.md @@ -27,9 +27,11 @@ Also don't forget to use `sudo` if you aren't in the `docker` group! 2. **Start all services**: ```bash - docker compose up -d + docker compose up --env-file backend/api/.env -d ``` + Note: the `--env-file` option is necessary as it will make the `REDIS_PASSWORD` environment variable available before the container is ran (and not only for the container itself, it is not the same as the compose attribute `env_file`). + This command will: - Build the backend and frontend images - Start PostgreSQL database @@ -50,6 +52,11 @@ If you prefer to start services individually: docker compose up db -d ``` +### Redis Only + ```bash + docker compose up --env-file backend/api/.env redis -d + ``` + ### Backend Api Only ```bash docker compose up backend -d diff --git a/docs/src/run-standard.md b/docs/src/run-standard.md index 615fe07b..a417fab0 100644 --- a/docs/src/run-standard.md +++ b/docs/src/run-standard.md @@ -7,6 +7,7 @@ This page explains how to install and run Arcadia directly on your system withou Before starting, ensure you have the following installed: - **PostgreSQL** - Database server +- **Redis** - Cache for the auth - **Rust & Cargo** - Required to build the backend - **Node.js & npm** - Required to build the frontend - **Git** - To clone the repository @@ -17,8 +18,9 @@ For development tool installation instructions, see the [Developer Setup](dev-se 1. Clone the repository and navigate to it 2. Set up PostgreSQL database -3. Configure and run the backend -4. Configure and run the frontend +3. Set up Redis +4. Configure and run the backend +5. Configure and run the frontend ## Database Setup @@ -83,6 +85,10 @@ cd backend/storage sqlx migrate run --database-url postgresql://arcadia:your_secure_password@localhost:5432/arcadia ``` +## Redis setup + +[Official docs](https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/) + ## Backend Setup ### 1. Environment Configuration