Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
services:
db:
image: postgres:15
container_name: volunchain_db
container_name: ${DB_CONTAINER_NAME:-volunchain_db}
environment:
POSTGRES_USER: volunchain
POSTGRES_PASSWORD: volunchain123
POSTGRES_DB: volunchain
POSTGRES_USER: ${POSTGRES_USER:-volunchain}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-volunchain123}
POSTGRES_DB: ${POSTGRES_DB:-volunchain}
Comment on lines +6 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Avoid shipping default credentials; require them via .env.

Defaulting POSTGRES_PASSWORD (and embedding it in DATABASE_URL) is a security smell. Make the password required and document it in .env.example.

       POSTGRES_USER: ${POSTGRES_USER:-volunchain}
-      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-volunchain123}
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}
       POSTGRES_DB: ${POSTGRES_DB:-volunchain}
-      DATABASE_URL: postgres://${POSTGRES_USER:-volunchain}:${POSTGRES_PASSWORD:-volunchain123}@db:5432/${POSTGRES_DB:-volunchain}
+      DATABASE_URL: postgres://${POSTGRES_USER:-volunchain}:${POSTGRES_PASSWORD:?set in .env}@db:5432/${POSTGRES_DB:-volunchain}

Optional: switch to env_file: .env and add a committed .env.example.

Also applies to: 29-29

πŸ€– Prompt for AI Agents
In docker-compose.yml around lines 6-8 (and line 29), the compose file currently
supplies default DB credentials via inline defaults which embeds a default
POSTGRES_PASSWORD (and other defaults) β€” remove the inline default values so
these vars are required from environment, and stop constructing a DATABASE_URL
with a defaulted password; instead add an env_file: .env to the service and
commit a .env.example that documents POSTGRES_USER, POSTGRES_PASSWORD,
POSTGRES_DB (and DATABASE_URL if used) with placeholder values and instructions.
Ensure docker-compose uses the variables as-is (no :- defaults), update any
DATABASE_URL construction to read from the required env var, and add
.env.example to the repo so developers know which variables to set.

ports:
- "5434:5432" # O usa "5432:5432" si necesitas que coincida localmente
- "${DB_HOST_PORT:-5434}:5432"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Bind services to localhost to avoid exposing them on all interfaces.

Limit DB/Redis exposure to the host only.

-      - "${DB_HOST_PORT:-5434}:5432"
+      - "127.0.0.1:${DB_HOST_PORT:-5434}:5432"
-      - "${REDIS_HOST_PORT:-6379}:6379"
+      - "127.0.0.1:${REDIS_HOST_PORT:-6379}:6379"

Also applies to: 23-23

πŸ€– Prompt for AI Agents
In docker-compose.yml around lines 10 and 23, the port mappings currently expose
DB and Redis on all network interfaces; change the mappings to bind to localhost
by prefixing host ports with 127.0.0.1 (e.g.
"127.0.0.1:${DB_HOST_PORT:-5434}:5432") for the DB and similarly for Redis so
both services are only accessible from the host loopback interface.

volumes:
- db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U volunchain"]
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-volunchain}"]
interval: 5s
retries: 5
timeout: 5s

redis:
image: redis:latest
container_name: volunchain_redis
container_name: ${REDIS_CONTAINER_NAME:-volunchain_redis}
ports:
- "6379:6379"
- "${REDIS_HOST_PORT:-6379}:6379"

app:
build: .
container_name: volunchain_app
container_name: ${APP_CONTAINER_NAME:-volunchain_app}
environment:
DATABASE_URL: postgres://volunchain:volunchain123@db:5432/volunchain
REDIS_URL: redis://redis:6379
DATABASE_URL: postgres://${POSTGRES_USER:-volunchain}:${POSTGRES_PASSWORD:-volunchain123}@db:5432/${POSTGRES_DB:-volunchain}
REDIS_URL: redis://redis:6379
command: sh -c "./entrypoint.sh"
depends_on:
db:
condition: service_healthy
redis:
condition: service_started

volumes:
db_data:
docker-compose.yml
git switch -c feature/docker-variables
Comment on lines +40 to +41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove stray, non-YAML lines breaking the compose file.

These two lines are literal text inside the YAML and cause the syntax error flagged by yamllint. Delete them.

 volumes:
   db_data:
-docker-compose.yml
-git switch -c feature/docker-variables
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker-compose.yml
git switch -c feature/docker-variables
volumes:
db_data:
🧰 Tools
πŸͺ› YAMLlint (1.37.1)

[error] 41-41: syntax error: could not find expected ':'

(syntax)

πŸ€– Prompt for AI Agents
In docker-compose.yml around lines 40 to 41 there are two stray non-YAML lines
("docker-compose.yml" and "git switch -c feature/docker-variables") embedded in
the file; remove those two literal lines so the file contains only valid YAML
content and re-run yamllint to verify syntax.