feat: add docker-compose configuration for evolution-api, redis, and postgres services#2527
feat: add docker-compose configuration for evolution-api, redis, and postgres services#2527Jubilio wants to merge 1 commit intoEvolutionAPI:mainfrom
Conversation
…postgres services
Reviewer's GuideAdds a new docker-compose configuration to run the evolution API alongside Redis and Postgres using a shared bridge network and .env-based configuration. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues, and left some high level feedback:
- Consider moving the hard-coded Postgres credentials (especially POSTGRES_PASSWORD) into the .env file so sensitive values are not committed in the compose file.
- You may want to add named volumes for Postgres (and possibly Redis) to ensure data persists across container restarts instead of relying solely on ephemeral container storage.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving the hard-coded Postgres credentials (especially POSTGRES_PASSWORD) into the .env file so sensitive values are not committed in the compose file.
- You may want to add named volumes for Postgres (and possibly Redis) to ensure data persists across container restarts instead of relying solely on ephemeral container storage.
## Individual Comments
### Comment 1
<location path="docker-compose.mwanga.yaml" line_range="4-13" />
<code_context>
+services:
+ api:
+ container_name: evolution_api
+ image: evoapicloud/evolution-api:latest
+ restart: always
+ depends_on:
+ - redis
+ - evolution_postgres
+ ports:
+ - "8080:8080"
+ env_file:
+ - .env
+ networks:
+ - evolution-net
+
+ redis:
+ container_name: evolution_redis
+ image: redis:latest
+ restart: always
+ networks:
</code_context>
<issue_to_address>
**suggestion:** Using `latest` tags for images can make deployments non-reproducible and harder to debug.
For both `api` and `redis`, please pin images to specific versions or digests (e.g. `evoapicloud/evolution-api:1.2.3`, `redis:7.2`) so updates are explicit and controlled.
Suggested implementation:
```
image: evoapicloud/evolution-api:1.2.3
```
```
image: redis:7.2
```
</issue_to_address>
### Comment 2
<location path="docker-compose.mwanga.yaml" line_range="32" />
<code_context>
+ environment:
+ - POSTGRES_DB=evolution_db
+ - POSTGRES_USER=postgres
+ - POSTGRES_PASSWORD=postgres_pass
+ networks:
+ - evolution-net
</code_context>
<issue_to_address>
**🚨 issue (security):** Hard-coding the database password in the compose file is a security risk.
Even for local use, embedding `POSTGRES_PASSWORD` in the compose file makes it easy to leak via version control or shared configs. Since you already use `.env`, reference the variable instead (e.g., `POSTGRES_PASSWORD=${POSTGRES_PASSWORD}`) and keep the actual secret only in `.env` or your secrets manager.
</issue_to_address>
### Comment 3
<location path="docker-compose.mwanga.yaml" line_range="23-13" />
<code_context>
+ networks:
+ - evolution-net
+
+ evolution_postgres:
+ container_name: evolution_postgres
+ image: postgres:15
+ restart: always
+ env_file:
+ - .env
+ environment:
+ - POSTGRES_DB=evolution_db
+ - POSTGRES_USER=postgres
+ - POSTGRES_PASSWORD=postgres_pass
+ networks:
+ - evolution-net
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Lack of a volume for Postgres means database data will be lost when the container is removed.
If this is meant for more than disposable local testing, define a named volume for `evolution_postgres` (e.g. `volumes: [evolution_postgres_data:/var/lib/postgresql/data]`) so data persists across container recreations and `docker-compose down` runs.
Suggested implementation:
```
evolution_postgres:
container_name: evolution_postgres
image: postgres:15
volumes:
- evolution_postgres_data:/var/lib/postgresql/data
```
You also need to declare the named volume `evolution_postgres_data` at the top level of the compose file, for example:
```yaml
volumes:
evolution_postgres_data:
```
Place this alongside the existing top-level `services:` / `networks:` keys (not nested under a service). If there is already a `volumes:` section, just add `evolution_postgres_data:` under it instead of creating a new `volumes:` key.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| image: evoapicloud/evolution-api:latest | ||
| restart: always | ||
| depends_on: | ||
| - redis | ||
| - evolution_postgres | ||
| ports: | ||
| - "8080:8080" | ||
| env_file: | ||
| - .env | ||
| networks: |
There was a problem hiding this comment.
suggestion: Using latest tags for images can make deployments non-reproducible and harder to debug.
For both api and redis, please pin images to specific versions or digests (e.g. evoapicloud/evolution-api:1.2.3, redis:7.2) so updates are explicit and controlled.
Suggested implementation:
image: evoapicloud/evolution-api:1.2.3
image: redis:7.2
| environment: | ||
| - POSTGRES_DB=evolution_db | ||
| - POSTGRES_USER=postgres | ||
| - POSTGRES_PASSWORD=postgres_pass |
There was a problem hiding this comment.
🚨 issue (security): Hard-coding the database password in the compose file is a security risk.
Even for local use, embedding POSTGRES_PASSWORD in the compose file makes it easy to leak via version control or shared configs. Since you already use .env, reference the variable instead (e.g., POSTGRES_PASSWORD=${POSTGRES_PASSWORD}) and keep the actual secret only in .env or your secrets manager.
| - "8080:8080" | ||
| env_file: | ||
| - .env | ||
| networks: |
There was a problem hiding this comment.
suggestion (bug_risk): Lack of a volume for Postgres means database data will be lost when the container is removed.
If this is meant for more than disposable local testing, define a named volume for evolution_postgres (e.g. volumes: [evolution_postgres_data:/var/lib/postgresql/data]) so data persists across container recreations and docker-compose down runs.
Suggested implementation:
evolution_postgres:
container_name: evolution_postgres
image: postgres:15
volumes:
- evolution_postgres_data:/var/lib/postgresql/data
You also need to declare the named volume evolution_postgres_data at the top level of the compose file, for example:
volumes:
evolution_postgres_data:Place this alongside the existing top-level services: / networks: keys (not nested under a service). If there is already a volumes: section, just add evolution_postgres_data: under it instead of creating a new volumes: key.
Summary by Sourcery
Deployment: