diff --git a/README.md b/README.md index fa1e4ef..01d5885 100644 --- a/README.md +++ b/README.md @@ -13,20 +13,17 @@

Local Development

> [!NOTE] -> Using [Nix](https://builtwithnix.org) is recommended for the development environment. If you're not using it, install Go and NodeJS. - Using [Docker](https://www.docker.com/) is required for database configuration. +> Using [Nix](https://builtwithnix.org) is recommended for the development environment. If you're not using it, install Go. For legacy maintence tasks, install NodeJS. -1. First, make sure you have a sane copy of Docker installed, and make sure the copy of Docker works. +1. Firstly, check if you have a working Nix environment if you're using Nix. -2. Secondly, check if you have a working Nix environment if you're using Nix. - -3. Lastly, Run `nix-shell`, or alternatively `source init.sh` if you're not using Nix. +2. Secondly, Run `nix-shell`, or alternatively `source init.sh` if you're not using Nix.

API Development

-1. After that, run the project in development mode: `npm run dev`. +1. After that, run the backend build script: `./build.sh`. -2. If you want to explore your database, run `npx prisma studio` to open the database editor. +2. Then, go into the `api/` directory, and then start it up: `go run . -b ../backends.dev.json`

Production Deployment

@@ -35,13 +32,15 @@ 1. Copy and change the default password (or username & db name too) from the template file `prod-docker.env`: ```bash - sed "s/POSTGRES_PASSWORD=nextnet/POSTGRES_PASSWORD=$(head -c 500 /dev/random | sha512sum | cut -d " " -f 1)/g" prod-docker.env > .env + sed "s/POSTGRES_PASSWORD=hermes/POSTGRES_PASSWORD=$(head -c 500 /dev/random | sha512sum | cut -d " " -f 1)/g" prod-docker.env > .env ``` 2. Build the docker stack: `docker compose --env-file .env up -d`

Troubleshooting

-* I'm using SSH tunneling, and I can't reach any of the tunnels publicly. +This has been moved [here.](docs/troubleshooting.md) - - Be sure to enable GatewayPorts in your sshd config (in `/etc/ssh/sshd_config` on most systems). Also, be sure to check your firewall rules on your system and your network. +

Documentation

+ +Go to the `docs/` folder. diff --git a/dev-docker-compose.yml b/dev-docker-compose.yml deleted file mode 100644 index c5ede8a..0000000 --- a/dev-docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This WILL NOT work for production deployments -# This file only contains dependencies for the backend and frontend, -# excluding the actual backend and frontend. - -services: - postgres: - image: postgres:17.2 - container_name: hermes-postgres - restart: always - environment: - POSTGRES_DB: nextnet - POSTGRES_PASSWORD: nextnet - POSTGRES_USER: nextnet - ports: - - 5432:5432 - volumes: - - nextnet_dev_postgres_data:/var/lib/postgresql/data - -volumes: - nextnet_dev_postgres_data: diff --git a/docker-compose.yml b/docker-compose.yml index 6255a09..565e8f8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ services: api: - image: ghcr.io/greysoh/nextnet:latest - container_name: nextnet-api + image: ghcr.io/imterah/hermes:latest + container_name: hermes-api restart: always env_file: - .env @@ -10,11 +10,13 @@ services: ports: - 3000:3000 + # WARN: The LOM is deprecated and likely broken currently. + # # NOTE: For this to work correctly, the nextnet-api must be version > 0.1.1 # or have a version with backported username support, incl. logins lom: - image: ghcr.io/greysoh/nextnet-lom:latest - container_name: nextnet-lom + image: ghcr.io/imterah/hermes-lom:latest + container_name: hermes-lom restart: always ports: - 2222:2222 diff --git a/docs/nextnet_to_hermes_migration.md b/docs/nextnet_to_hermes_migration.md new file mode 100644 index 0000000..4f0f6f4 --- /dev/null +++ b/docs/nextnet_to_hermes_migration.md @@ -0,0 +1,28 @@ +# NextNet to Hermes migration +## Other Environment Variables +Below are existing environment variables that need to be migrated over from NextNet to Hermes, untouched: + * `IS_SIGNUP_ENABLED` -> `HERMES_SIGNUP_ENABLED` + * `UNSAFE_ADMIN_SIGNUP` -> `HERMES_UNSAFE_ADMIN_SIGNUP_ENABLED` +Below are new environment variables that may need to be set up: + * `HERMES_FORCE_DISABLE_REFRESH_TOKEN_EXPIRY`: Disables refresh token expiry for Hermes. Instead of the singular token structure used + by NextNet, there is now a refresh token and JWT token combination. + * `HERMES_LOG_LEVEL`: Log level for Hermes & Hermes backends to run at. + * `HERMES_DEVELOPMENT_MODE`: Development mode for Hermes, disabling security features. + * `HERMES_LISTENING_ADDRESS`: Address to listen on for the API server. Example: `0.0.0.0:8000`. + * `HERMES_TRUSTED_HTTP_PROXIES`: List of trusted HTTP proxies separated by commas. +## Database-Related Environment Variables + * `HERMES_DATABASE_BACKEND`: Can be either `sqlite` for the embedded SQLite-compliant database, or `postgresql` for PostgreSQL support. + * `HERMES_SQLITE_FILEPATH`: Path for the SQLite database to use. + * `HERMES_POSTGRES_DSN`: PostgreSQL DSN for Golang. An example value which should work with minimal changes for PostgreSQL databases is `postgres://username:password@localhost:5432/database_name`. +## Migration steps +1. Add the supporting environment variable for Prisma: `DATABASE_URL` -> `postgresql://$POSTGRES_USERNAME:$POSTGRES_PASSWORD@nextnet-postgres:5432/$POSTGRES_DB`. +2. Remove all old environment variables. +3. Add these variables: + - `HERMES_DATABASE_BACKEND` -> `postgresql` + - `HERMES_POSTGRES_DSN` -> `postgres://$POSTGRES_USERNAME:$POSTGRES_PASSWORD@nextnet-postgres:5432/$POSTGRES_DB` + - `DATABASE_URL` -> `postgresql://$POSTGRES_USERNAME:$POSTGRES_PASSWORD@nextnet-postgres:5432/$POSTGRES_DB?schema=nextnet` +4. Switch the API docker image from `ghcr.io/imterah/nextnet:latest` to `ghcr.io/imterah/hermes-backend-migration:latest` +5. Go get the container logs, and make sure no errors get output to the console. +6. Copy the backup as instructed in the log file. +7. DO NOT RESTART THE CONTAINER IF SUCCESSFUL. YOU WILL LOSE ALL YOUR DATA. If the migration fails, follow the steps mentioned in the logs. +8. If successful, switch the API docker image from `ghcr.io/imterah/hermes-backend-migration:latest` to `ghcr.io/imterah/hermes:latest`. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md new file mode 100644 index 0000000..75324d3 --- /dev/null +++ b/docs/troubleshooting.md @@ -0,0 +1,4 @@ +# Troubleshooting + +* I'm using SSH tunneling, and I can't reach any of the tunnels publicly. + - Be sure to enable GatewayPorts in your sshd config (in `/etc/ssh/sshd_config` on most systems). Also, be sure to check your firewall rules on your system and your network. diff --git a/prod-docker.env b/prod-docker.env index dcc049b..fe5da79 100644 --- a/prod-docker.env +++ b/prod-docker.env @@ -1,5 +1,5 @@ # These are default values, please change these! -POSTGRES_USERNAME=nextnet -POSTGRES_PASSWORD=nextnet -POSTGRES_DB=nextnet \ No newline at end of file +POSTGRES_USERNAME=hermes +POSTGRES_PASSWORD=hermes +POSTGRES_DB=hermes