diff --git a/README.md b/README.md index af8154f..a4ef6c5 100644 --- a/README.md +++ b/README.md @@ -25,19 +25,44 @@ Random Port Generator ## Deployment -Simply run this compose.yml: +PortNote uses docker compose for deployment. It is crucial +to set up some secrets for the environment to make your +deployment work. One could do that by creating a `.env` +file with following content: + +```dotenv +JWT_SECRET=# Replace with a secure random string +USER_SECRET=# Replace with a secure random string +LOGIN_USERNAME=# Replace with a username +LOGIN_PASSWORD=# Replace with a custom password +``` + +To quickly generate such file, one can execute a following +command: + +> Note: it will overwrite the .env file if it already exists + +```sh +echo """ +JWT_SECRET=$(openssl rand -base64 32) +USER_SECRET=$(openssl rand -base64 32) +LOGIN_USERNAME=some_user +LOGIN_PASSWORD=some_password +""" > .en +``` + +Adjust the values to your needs and then run the following +[compose.yaml](compose.yml): + ```yml services: web: image: haedlessdev/portnote:latest ports: - "3000:3000" + env_file: .env environment: - JWT_SECRET: RANDOM_SECRET # Replace with a secure random string - USER_SECRET: RANDOM_SECRET # Replace with a secure random string - LOGIN_USERNAME: username # Replace with a username - LOGIN_PASSWORD: mypassword # Replace with a custom password - DATABASE_URL: "postgresql://postgres:postgres@db:5432/postgres" + DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" depends_on: db: condition: service_started @@ -45,7 +70,7 @@ services: agent: image: haedlessdev/portnote-agent:latest environment: - DATABASE_URL: "postgresql://postgres:postgres@db:5432/postgres" + DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" depends_on: db: condition: service_started @@ -64,6 +89,12 @@ volumes: postgres_data: ``` +Deploy with a command: + +```sh +docker compose -f compose.yml -d +``` + ## Tech Stack & Credits The application is build with: diff --git a/compose.yml b/compose.yml index cdd5614..331ffba 100644 --- a/compose.yml +++ b/compose.yml @@ -3,12 +3,9 @@ services: image: haedlessdev/portnote:latest ports: - "3000:3000" + env_file: .env environment: - JWT_SECRET: RANDOM_SECRET # Replace with a secure random string - USER_SECRET: RANDOM_SECRET # Replace with a secure random string - LOGIN_USERNAME: username # Replace with a username - LOGIN_PASSWORD: mypassword # Replace with a custom password - DATABASE_URL: "postgresql://postgres:postgres@db:5432/postgres" + DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" depends_on: db: condition: service_started @@ -16,7 +13,7 @@ services: agent: image: haedlessdev/portnote-agent:latest environment: - DATABASE_URL: "postgresql://postgres:postgres@db:5432/postgres" + DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" depends_on: db: condition: service_started