diff --git a/DEVELOPER_SETUP.md b/DEVELOPER_SETUP.md index 6e4054bba..699b4900e 100644 --- a/DEVELOPER_SETUP.md +++ b/DEVELOPER_SETUP.md @@ -1,8 +1,45 @@ -# Setup for development environment +# Setting up RomM for development -## Environment setup +## Option 1: Using Docker -### Mocking RomM structure +If you prefer to use Docker for development, you can set up RomM using the provided Docker Compose configuration. This method simplifies the setup process by encapsulating all dependencies within Docker containers. + +### Environment setup + +#### Create the mock structure with at least one rom and empty config for manual testing + +```sh +mkdir -p romm_mock/library/roms/switch +touch romm_mock/library/roms/switch/metroid.xci +mkdir -p romm_mock/resources +mkdir -p romm_mock/assets +mkdir -p romm_mock/config +touch romm_mock/config/config.yml +``` + +#### Copy env.template to .env and fill the variables + +```sh +cp env.template .env +``` + +#### Build the image + +```sh +docker compose build # or `docker compose build --no-cache` to rebuild from scratch +``` + +#### Spin up the Docker containers + +```sh +docker compose up -d +``` + +And you're done! You can access the app at `http://localhost:3000`. Any changes made to the code will be automatically reflected in the app thanks to the volume mounts. + +## Option 2: Manual setup + +### Environment setup #### - Create the mock structure with at least one rom and empty config for manual testing @@ -15,8 +52,6 @@ mkdir -p romm_mock/config touch romm_mock/config/config.yml ``` -### Setting up the backend - #### - Copy env.template to .env and fill the variables ```sh @@ -30,7 +65,8 @@ cp env.template .env sudo apt install libmariadb3 libmariadb-dev libpq-dev pipx # Build and configure RAHasher (optional) -# IMPORTANT! This is only required to calculate RA hashes. This is needed only if RA API is going to be enabled +# This is only required to calculate RA hashes +# Users on macOS can skip this step as RAHasher is not supported git clone --recursive https://github.com/RetroAchievements/RALibretro.git cd ./RALibretro git checkout 1.8.0 @@ -65,7 +101,7 @@ If you are on Arch Linux or another Arch-based distro, you need to run the comma CFLAGS="-Wno-error=incompatible-pointer-types" poetry sync --all-extras ``` -#### - Spin up mariadb in docker +#### - Spin up the database and other services ```sh docker compose up -d @@ -101,8 +137,8 @@ npm install ```sh mkdir assets/romm -ln -s ../backend/romm_mock/resources assets/romm/resources -ln -s ../backend/romm_mock/assets assets/romm/assets +ln -s ../romm_mock/resources assets/romm/resources +ln -s ../romm_mock/assets assets/romm/assets ``` #### - Run the frontend @@ -111,11 +147,11 @@ ln -s ../backend/romm_mock/assets assets/romm/assets npm run dev ``` -### Setting up the linter +## Setting up the linter We use [Trunk](https://trunk.io) for linting, which combines multiple linters and formatters with sensible defaults and a single configuration file. You'll need to install the Trunk CLI to use it. -#### - Install the Trunk CLI +### - Install the Trunk CLI ```sh curl https://get.trunk.io -fsSL | bash diff --git a/Dockerfile b/Dockerfile index 43fc711ca..b8247e64e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ ENV PATH="/usr/local/bin:$HOME/.local/bin:${PATH}" COPY pyproject.toml poetry.lock* .python-version /app/ # Install Python dependencies -RUN poetry sync +RUN poetry sync --all-extras # Copy entrypoint script COPY entrypoint.sh /entrypoint.sh diff --git a/docker-compose.yml b/docker-compose.yml index 68fd14ef3..e39832b17 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,8 +33,7 @@ services: image: mariadb:11.3.2 container_name: romm-db-dev restart: unless-stopped - env_file: - - .env + env_file: .env environment: - MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWD:-rootpassword} - MARIADB_DATABASE=${DB_NAME:-romm} @@ -49,8 +48,7 @@ services: image: valkey/valkey:8 container_name: romm-valkey-dev restart: unless-stopped - env_file: - - .env + env_file: .env ports: - "${REDIS_PORT:-6379}:6379" @@ -58,8 +56,7 @@ services: image: postgres:16-alpine container_name: romm-postgresql-dev restart: unless-stopped - env_file: - - .env + env_file: .env environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} POSTGRES_USER: ${POSTGRES_USER:-postgres} @@ -74,8 +71,7 @@ services: container_name: romm-authentik-server restart: unless-stopped command: server - env_file: - - .env + env_file: .env environment: AUTHENTIK_REDIS__HOST: romm-valkey-dev AUTHENTIK_POSTGRESQL__HOST: romm-postgres-dev @@ -99,8 +95,7 @@ services: container_name: romm-authentik-worker restart: unless-stopped command: worker - env_file: - - .env + env_file: .env environment: AUTHENTIK_REDIS__HOST: romm-valkey-dev AUTHENTIK_POSTGRESQL__HOST: romm-postgres-dev diff --git a/entrypoint.sh b/entrypoint.sh index 4cea384a6..643c56a6e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,16 +1,12 @@ #!/bin/bash set -e -# Copy env template if .env doesn't exist -if [[ ! -f /app/.env ]]; then - cp /app/env.template /app/.env - echo "Created .env file from template. Please edit with your configuration." -fi +echo "Starting entrypoint script..." # Create symlinks for frontend mkdir -p /app/frontend/assets/romm -ln -sf /app/romm_mock/resources /app/frontend/assets/romm/resources -ln -sf /app/romm_mock/assets /app/frontend/assets/romm/assets +ln -sf /app/romm/resources /app/frontend/assets/romm/resources +ln -sf /app/romm/assets /app/frontend/assets/romm/assets # Define a signal handler to propagate termination signals function handle_termination() { @@ -21,6 +17,7 @@ function handle_termination() { # Trap SIGTERM and SIGINT signals trap handle_termination SIGTERM SIGINT + # Start all services in the background cd /app/backend poetry run python main.py &