-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Upgrade docker compose Postgres + Redis #602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Upgrade docker compose Postgres + Redis #602
Conversation
🦋 Changeset detectedLatest commit: 4bdac4c The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis change enhances the Docker Compose generation in the core generators package by upgrading PostgreSQL and Redis versions, improving security and networking, refining environment variable management, and updating interfaces and generator signatures. It introduces new configuration parameters, custom network support, and generates both Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DockerComposeGenerator
participant PostgresGenerator
participant RedisGenerator
participant FileSystem
User->>DockerComposeGenerator: Invoke generator with config
DockerComposeGenerator->>PostgresGenerator: Generate Postgres YAML (with database, projectName)
DockerComposeGenerator->>RedisGenerator: Generate Redis YAML (with projectName)
DockerComposeGenerator->>DockerComposeGenerator: Add custom network config
DockerComposeGenerator->>DockerComposeGenerator: Prepare .env and .env.example files
DockerComposeGenerator->>FileSystem: Write docker-compose.yaml, .env, .env.example
FileSystem-->>User: Files generated
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/core-generators/src/generators/docker/docker-compose/docker-compose.generator.ts (1)
100-100: Consider environment naming convention.The current naming uses
${projectName}-devfor the compose project name. Based on the retrieved learnings about environment naming conventions, consider if this aligns with your project's environment naming standards.If you follow different environment naming conventions, you might want to make this configurable:
- const envVars = [`COMPOSE_PROJECT_NAME=${projectName}-dev`]; + const envVars = [`COMPOSE_PROJECT_NAME=${projectName}-dev`]; // or make this configurable.changeset/improve-docker-compose-security.md (1)
11-11: Fix markdown formatting for the URL.The bare URL should be properly formatted to resolve the markdown lint issue.
Apply this fix:
-- For existing projects, follow the upgrade guide at https://docs.baseplate.dev/guides/upgrading-postgres/ +- For existing projects, follow the upgrade guide at <https://docs.baseplate.dev/guides/upgrading-postgres/>
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.changeset/improve-docker-compose-security.md(1 hunks)packages/core-generators/src/generators/docker/docker-compose/docker-compose.generator.ts(5 hunks)packages/core-generators/src/generators/docker/docker-compose/postgres.ts(2 hunks)packages/core-generators/src/generators/docker/docker-compose/redis.ts(1 hunks)packages/core-generators/src/generators/docker/docker-compose/types.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
`**/*.{ts,tsx}`: TypeScript with strict type checking Node 16 module resolution ...
**/*.{ts,tsx}: TypeScript with strict type checking
Node 16 module resolution - include file extensions in imports (.js)
Sort imports by group: external libs first, then local imports
Use camelCase for variables/functions, PascalCase for types/classes
Always include return types on top-level functions including React components (React.ReactElement)
Include absolute paths in import statements via tsconfig paths (@src/is the alias forsrc/)
Order functions such that functions are placed below the variables/functions they use
If a particular interface or type is not exported, change the file so it is exported
Prefer using nullish coalescing operator (??) instead of logical or (||)
Use console.info/warn/error instead of console.log
Always use.jsextensions in imports, even for TypeScript files
Specify explicit return types on all functions
📄 Source: CodeRabbit Inference Engine (CLAUDE.md)
List of files the instruction was applied to:
packages/core-generators/src/generators/docker/docker-compose/types.tspackages/core-generators/src/generators/docker/docker-compose/postgres.tspackages/core-generators/src/generators/docker/docker-compose/redis.tspackages/core-generators/src/generators/docker/docker-compose/docker-compose.generator.ts
`**/*`: Use kebab-case for file names
**/*: Use kebab-case for file names
📄 Source: CodeRabbit Inference Engine (CLAUDE.md)
List of files the instruction was applied to:
packages/core-generators/src/generators/docker/docker-compose/types.tspackages/core-generators/src/generators/docker/docker-compose/postgres.tspackages/core-generators/src/generators/docker/docker-compose/redis.tspackages/core-generators/src/generators/docker/docker-compose/docker-compose.generator.ts
`{packages,plugins}/**/*.{ts,tsx}`: Use TypeScript with strict type checking ena...
{packages,plugins}/**/*.{ts,tsx}: Use TypeScript with strict type checking enabled
All functions (excluding one-liner arrow functions) require explicit return types
Use camelCase for variables and functions
Use PascalCase for types and classes
Prefer functional programming patterns
Extract repeated components into distinct functions or components where applicable
📄 Source: CodeRabbit Inference Engine (.cursor/rules/code-style.mdc)
List of files the instruction was applied to:
packages/core-generators/src/generators/docker/docker-compose/types.tspackages/core-generators/src/generators/docker/docker-compose/postgres.tspackages/core-generators/src/generators/docker/docker-compose/redis.tspackages/core-generators/src/generators/docker/docker-compose/docker-compose.generator.ts
`.changeset/*.md`: If you are adding a new feature or changing an existing feature, add a new Changeset in the `.changeset/` directory
.changeset/*.md: If you are adding a new feature or changing an existing feature, add a new Changeset in the.changeset/directory
📄 Source: CodeRabbit Inference Engine (CLAUDE.md)
List of files the instruction was applied to:
.changeset/improve-docker-compose-security.md
🧠 Learnings (1)
packages/core-generators/src/generators/docker/docker-compose/docker-compose.generator.ts (1)
Learnt from: kingston
PR: halfdomelabs/baseplate#598
File: packages/fastify-generators/src/generators/yoga/yoga-plugin/templates/src/plugins/graphql/index.ts:18-18
Timestamp: 2025-07-10T06:49:07.704Z
Learning: In React projects using Vite, keep the .env file naming convention as .env.development, .env.production, etc. even when internal application environment values use shorter abbreviations like 'dev', 'stage', 'prod'. This follows Vite's mode conventions.
🪛 markdownlint-cli2 (0.17.2)
.changeset/improve-docker-compose-security.md
11-11: Bare URL used
(MD034, no-bare-urls)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test
- GitHub Check: Test E2E
- GitHub Check: Lint
🔇 Additional comments (11)
packages/core-generators/src/generators/docker/docker-compose/types.ts (1)
4-4: LGTM! Clean interface extension for network support.The addition of the optional
networksproperty properly supports the new custom bridge network feature introduced in this PR.packages/core-generators/src/generators/docker/docker-compose/redis.ts (2)
3-7: Good interface name fix and configuration extension.The interface rename from
PostgresConfigtoRedisConfigcorrectly fixes the bug mentioned in the changeset. The addition ofprojectNamealigns with the new container naming strategy.
22-22: Verify Redis CLI options in Docker ComposePlease confirm the following before merging:
- The template string
\${REDIS_PASSWORD:-${config.password}}is escaped correctly in the generateddocker-compose.ymlso that Docker Compose sees${REDIS_PASSWORD:-default}as intended.- A 256 MB
--maxmemorylimit with--maxmemory-policy noevictionwon’t cause unexpected failures under our BullMQ workload—once Redis hits the cap, writes will error out.- The
--save 20 1RDB snapshot policy fits our durability vs. performance requirements (or consider disabling RDB or using AOF if we need different persistence guarantees).packages/core-generators/src/generators/docker/docker-compose/postgres.ts (3)
6-8: Good interface extension for database configuration.The addition of
databaseandprojectNamefields properly supports the enhanced configuration requirements and aligns with the Redis interface changes.
16-25: Excellent PostgreSQL configuration updates.The version upgrade to 17.5-alpine, security options, and environment variable configuration are well-implemented. The
POSTGRES_INITDB_ARGSwith UTF8 encoding is a good practice for consistent database initialization.
37-41: Well-configured PostgreSQL healthcheck.The healthcheck correctly specifies the database and includes appropriate timing parameters with the start period. This ensures reliable container health monitoring.
packages/core-generators/src/generators/docker/docker-compose/docker-compose.generator.ts (4)
18-18: Good schema extension for database configuration.The addition of the optional
databasefield to the postgres schema aligns with the PostgreSQL interface updates and provides flexibility for database naming.
53-55: Correct parameter passing for updated interfaces.The function calls are properly updated to include the new
databaseandprojectNameparameters, maintaining consistency with the interface changes.
84-93: Well-implemented network configuration.The custom bridge network generation is correctly implemented and only added when services exist. This provides proper network isolation for the services.
99-134: Excellent environment variable management.The comprehensive environment variable generation for both
.envand.env.examplefiles with proper documentation comments significantly improves the developer experience..changeset/improve-docker-compose-security.md (1)
1-49: Comprehensive and well-documented changeset.The changeset thoroughly documents all the improvements including version upgrades, security enhancements, networking improvements, and developer experience features. This provides excellent visibility into the changes for users.
| test: ["CMD", "redis-cli", "ping"] | ||
| interval: 5s | ||
| timeout: 2s | ||
| retries: 2`, | ||
| retries: 2 | ||
| start_period: 10s`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix Redis healthcheck to include authentication.
The healthcheck command redis-cli ping will fail when a password is required. When Redis has authentication enabled, the ping command needs to authenticate.
Apply this fix to make the healthcheck work with password authentication:
- test: ["CMD", "redis-cli", "ping"]
+ test: ["CMD", "redis-cli", "--no-auth-warning", "ping"]Or alternatively, use a more robust approach:
- test: ["CMD", "redis-cli", "ping"]
+ test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]📝 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.
| test: ["CMD", "redis-cli", "ping"] | |
| interval: 5s | |
| timeout: 2s | |
| retries: 2`, | |
| retries: 2 | |
| start_period: 10s`, | |
| test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"] | |
| interval: 5s | |
| timeout: 2s | |
| retries: 2 | |
| start_period: 10s`, |
🤖 Prompt for AI Agents
In packages/core-generators/src/generators/docker/docker-compose/redis.ts around
lines 33 to 37, the Redis healthcheck command uses `redis-cli ping` which fails
if Redis requires authentication. Update the healthcheck command to include the
password by adding the `-a <password>` option to the `redis-cli` command,
ensuring it authenticates before sending the ping. Replace the existing test
command with one that includes authentication or use a more robust approach that
handles password securely.
Summary by CodeRabbit
New Features
.env.examplefiles to document environment variables for easier setup.Bug Fixes
Breaking Changes