From 97a6355a6ba24eed26f2db4d0996387e7c869ee2 Mon Sep 17 00:00:00 2001 From: tylen Date: Sat, 17 May 2025 22:44:31 +0300 Subject: [PATCH 1/2] docker: remove secrets from compose.yml Move secret handling to .env --- README.md | 46 +++++++++++++++++++++++++++++++++++++++------- compose.yml | 10 ++++------ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index af8154f..7790869 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,35 @@ 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: @@ -33,11 +61,9 @@ services: ports: - "3000:3000" 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" + env_file: + - .env depends_on: db: condition: service_started @@ -45,7 +71,7 @@ services: agent: image: haedlessdev/portnote-agent:latest environment: - DATABASE_URL: "postgresql://postgres:postgres@db:5432/postgres" + - DATABASE_URL: "postgresql://postgres:postgres@db:5432/postgres" depends_on: db: condition: service_started @@ -64,6 +90,12 @@ volumes: postgres_data: ``` +Deploy with a command: + +```sh +docker-compose -f compose.yml --env-file .env up -d +``` + ## Tech Stack & Credits The application is build with: diff --git a/compose.yml b/compose.yml index cdd5614..b0b9ecb 100644 --- a/compose.yml +++ b/compose.yml @@ -4,11 +4,9 @@ services: ports: - "3000:3000" 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" + env_file: + - .env depends_on: db: condition: service_started @@ -16,7 +14,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 From 8df9df5820d5bc8581ce9e567f38b499d7b5b9af Mon Sep 17 00:00:00 2001 From: tylen Date: Sat, 17 May 2025 22:44:31 +0300 Subject: [PATCH 2/2] docker: remove secrets from compose.yml Move secret handling to .env --- README.md | 9 ++++----- compose.yml | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7790869..a4ef6c5 100644 --- a/README.md +++ b/README.md @@ -60,10 +60,9 @@ services: image: haedlessdev/portnote:latest ports: - "3000:3000" + env_file: .env environment: - - DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" - env_file: - - .env + DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" depends_on: db: condition: service_started @@ -71,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 @@ -93,7 +92,7 @@ volumes: Deploy with a command: ```sh -docker-compose -f compose.yml --env-file .env up -d +docker compose -f compose.yml -d ``` ## Tech Stack & Credits diff --git a/compose.yml b/compose.yml index b0b9ecb..331ffba 100644 --- a/compose.yml +++ b/compose.yml @@ -3,10 +3,9 @@ services: image: haedlessdev/portnote:latest ports: - "3000:3000" + env_file: .env environment: - - DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" - env_file: - - .env + DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" depends_on: db: condition: service_started @@ -14,7 +13,7 @@ services: agent: image: haedlessdev/portnote-agent:latest environment: - - DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" + DATABASE_URL: "postgresql://postgres:postgres@172.20.0.2:5432/postgres" depends_on: db: condition: service_started