Skip to content

Add compose.yml for new apps#403

Merged
timriley merged 1 commit into
mainfrom
aa/roadmap/27
Jun 4, 2026
Merged

Add compose.yml for new apps#403
timriley merged 1 commit into
mainfrom
aa/roadmap/27

Conversation

@aaronmallen

@aaronmallen aaronmallen commented Apr 26, 2026

Copy link
Copy Markdown
Member

Summary

Generates a compose.yml file when a new app is created with either the postgres or mysql database adapter, so users can spin up a local database with docker compose up without any extra setup.

Design choices

Why compose.yml instead of docker-compose.yml

The Compose Specification (which Docker Compose v2 implements) treats compose.yaml / compose.yml as the canonical filename. docker-compose.yml is still supported, but only for backwards compatibility with v1.

From the Docker documentation:

The default path for a Compose file is compose.yaml (preferred) or compose.yml... Compose also supports docker-compose.yaml and docker-compose.yml for backwards compatibility.

Generating new projects with the modern name avoids steering users toward a legacy convention they would eventually need to migrate away from.

Why the database has no password

The generated compose.yml uses POSTGRES_HOST_AUTH_METHOD: trust for Postgres and MYSQL_ALLOW_EMPTY_PASSWORD: "yes" for MySQL. A few reasons:

  1. It is a local development starter, not a production artifact. Anyone deploying this stack to a real environment is expected to replace the file (or its credentials), which is the same assumption every framework starter makes.
  2. Zero credential plumbing. A generated password would need to be threaded through .env, config/db.rb, and the compose environment block, and kept in sync across all three. Any drift produces a confusing connection error on first run, which is a bad first experience for a brand new app.
  3. Not network reachable in a meaningful way. The container only binds to localhost, so the unauthenticated socket is not exposed beyond the developer's machine.
  4. Matches the expectations of hanami db create out of the box. Users can run hanami new, docker compose up, and hanami db create in sequence with no further configuration.

closes hanami/roadmap/issues/27

@aaronmallen aaronmallen requested review from cllns and timriley April 26, 2026 16:52
@aaronmallen aaronmallen added the enhancement New feature or request label Apr 26, 2026
@github-actions

github-actions Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

ℹ️ Optional job failed: Ruby jruby

- 5432:5432
environment:
POSTGRES_DB: <%= app %>
POSTGRES_HOST_AUTH_METHOD: trust

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is great! Usually I do postgres:postgres@localhost anyway.

@timriley timriley merged commit c6e4158 into main Jun 4, 2026
13 checks passed
@timriley timriley deleted the aa/roadmap/27 branch June 4, 2026 11:45
@timriley

timriley commented Jun 4, 2026

Copy link
Copy Markdown
Member

Thanks @aaronmallen!

@timriley

timriley commented Jun 4, 2026

Copy link
Copy Markdown
Member

Two follow-up tasks: #415 and #416

timriley added a commit that referenced this pull request Jun 5, 2026
This reverts commit c6e4158.

Defaulting to a database in Docker turned out to be too much for us to chew off before our upcoming release. We need to consider e.g. how the `db` CLI commands invoke database CLIs like `pg_dump`, `pg_restore`, etc.
@timriley

timriley commented Jun 5, 2026

Copy link
Copy Markdown
Member

I reverted this in 644e8ea. This turned out to be a much bigger problem to solve. We need to factor in how our db CLI commands invoke database-specific CLIs on the host machine, which Docker doesn't solve at all. We should think about this more holistically and take another run at it in a future release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate a docker-compose.yml based on the chosen database type

3 participants