From 57058eae74d8dc9c5dfb8e273cf2c647d9a3092f Mon Sep 17 00:00:00 2001 From: SanthoshKumar1903 Date: Thu, 13 Nov 2025 13:30:23 +0530 Subject: [PATCH 1/5] Added posgreSQL for local dev --- postgres.Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 postgres.Dockerfile diff --git a/postgres.Dockerfile b/postgres.Dockerfile new file mode 100644 index 00000000..067f4e07 --- /dev/null +++ b/postgres.Dockerfile @@ -0,0 +1,7 @@ +FROM postgres:18.0-alpine3.22 + +ENV POSTGRES_USER=opensox +ENV POSTGRES_PASSWORD=opensox +ENV POSTGRES_DB=opensox + +EXPOSE 5432 From a5ba55422c52a4147f7b3e9dcf1fc40551f015fe Mon Sep 17 00:00:00 2001 From: SanthoshKumar1903 Date: Mon, 8 Dec 2025 13:04:29 +0530 Subject: [PATCH 2/5] Added docker-compose.dev.yml for local development --- .env.example | 7 +++++++ README.md | 42 +++++++----------------------------------- docker-compose.dev.yml | 18 ++++++++++++++++++ postgres.Dockerfile | 7 ------- 4 files changed, 32 insertions(+), 42 deletions(-) create mode 100644 .env.example create mode 100644 docker-compose.dev.yml delete mode 100644 postgres.Dockerfile diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..77fcf1b1 --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +# Create a .env file in root directory and add these values. You can simply copy it as cp .env.example .env +# Then run docker compose -f docker-compose.dev.yml up to start postgres inside docker and run migartions if you want +# Don't forget to add the same username, password and DB name to run backend api at /apps/api inside .env + +POSTGRES_USER=opensox +POSTGRES_PASSWORD=opensox_dev_password +POSTGRES_DB=opensox \ No newline at end of file diff --git a/README.md b/README.md index d51d2650..a6c37b51 100644 --- a/README.md +++ b/README.md @@ -227,44 +227,16 @@ docker run -p 4000:4000 \ Your API server will be available at `http://localhost:4000`. -### Using Docker Compose (Optional) - -For a complete setup with PostgreSQL, you can create a `docker-compose.yml` file: - -```yaml -version: '3.8' -services: - postgres: - image: postgres:15 - environment: - POSTGRES_USER: opensox - POSTGRES_PASSWORD: opensox - POSTGRES_DB: opensox - ports: - - "5432:5432" - volumes: - - postgres_data:/var/lib/postgresql/data - - api: - build: . - ports: - - "4000:4000" - environment: - DATABASE_URL: postgresql://opensox:opensox@postgres:5432/opensox?schema=public - JWT_SECRET: your-secret-key - PORT: 4000 - NODE_ENV: production - depends_on: - - postgres - -volumes: - postgres_data: -``` +### Using Docker Compose for Database (Only) -Then run: +For a DB setup with PostgreSQL, cp .env.example .env in root directry with required variables, then run docker-compose.dev.yml ```bash -docker-compose up -d +cp .env.example .env +``` +Then run, +```bash +docker-compose -f docker-compose.dev.yml up -d ``` ## Our contributors diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 00000000..59e71692 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,18 @@ + +services: + postgres: + image: postgres:18 + env_file: + - .env + ports: + - "5432:5432" + volumes: + - opensox_postgres_data:/var/lib/postgresql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U opensox"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + opensox_postgres_data: diff --git a/postgres.Dockerfile b/postgres.Dockerfile deleted file mode 100644 index 067f4e07..00000000 --- a/postgres.Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM postgres:18.0-alpine3.22 - -ENV POSTGRES_USER=opensox -ENV POSTGRES_PASSWORD=opensox -ENV POSTGRES_DB=opensox - -EXPOSE 5432 From 1f6ce416eee8f92263faa7814724bf5144654644 Mon Sep 17 00:00:00 2001 From: Santhoshkumar M M Date: Mon, 8 Dec 2025 13:36:20 +0530 Subject: [PATCH 3/5] Update .env.example Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .env.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 77fcf1b1..9380d331 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ # Create a .env file in root directory and add these values. You can simply copy it as cp .env.example .env -# Then run docker compose -f docker-compose.dev.yml up to start postgres inside docker and run migartions if you want +# Then run docker compose -f docker-compose.dev.yml up to start postgres inside docker and run migrations if you want # Don't forget to add the same username, password and DB name to run backend api at /apps/api inside .env -POSTGRES_USER=opensox +POSTGRES_DB=opensox POSTGRES_PASSWORD=opensox_dev_password -POSTGRES_DB=opensox \ No newline at end of file +POSTGRES_USER=opensox From dc5e3d78c13827db91c0ff56f9261acce35afd1a Mon Sep 17 00:00:00 2001 From: Santhoshkumar M M Date: Mon, 8 Dec 2025 13:42:20 +0530 Subject: [PATCH 4/5] Update docker-compose.dev.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docker-compose.dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 59e71692..9023682b 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -9,7 +9,7 @@ services: volumes: - opensox_postgres_data:/var/lib/postgresql healthcheck: - test: ["CMD-SHELL", "pg_isready -U opensox"] + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"] interval: 10s timeout: 5s retries: 5 From fca17c2e1590b6960cfcceb1d46d25ad775dfdeb Mon Sep 17 00:00:00 2001 From: SanthoshKumar1903 Date: Mon, 8 Dec 2025 13:50:11 +0530 Subject: [PATCH 5/5] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a6c37b51..1eaf7b48 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ Your API server will be available at `http://localhost:4000`. ### Using Docker Compose for Database (Only) -For a DB setup with PostgreSQL, cp .env.example .env in root directry with required variables, then run docker-compose.dev.yml +For a DB setup with PostgreSQL, cp .env.example .env in root directory with required variables, then run docker-compose.dev.yml ```bash cp .env.example .env