Skip to content
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: Add docker compose #2049

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

NathanaelRea
Copy link

Closes #

✅ Checklist

  • I have followed every step in the contributing guide (updated 2022-10-06).
  • The PR title follows the convention we established conventional-commit
  • I performed a functional test on my final commit

Changelog

Add docker-compose.yml file for postgres and mysql database options. start-database.sh now exports the needed environment variables and calls docker compose up -d. This serves as a more observable example, and is more extensible if the user wants to add services.

Moves forward #1927 because the user can now run docker compose up -d, but not complete because would probably want to:

  1. Unify ./start-databse.sh into an entrypoint for a Dockerfile (one line difference - setting container name)
  2. Move generate db password into cli after choosing db provider to simplify start-database.yml

Screenshots

[Screenshots]

💯

Copy link

changeset-bot bot commented Jan 25, 2025

🦋 Changeset detected

Latest commit: 8d2ce67

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-t3-app Patch

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

Copy link

vercel bot commented Jan 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
create-t3-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 25, 2025 1:21am

Copy link

vercel bot commented Jan 25, 2025

@NathanaelRea is attempting to deploy a commit to the t3-oss Team on Vercel.

A member of the Team first needs to authorize it.

@NathanaelRea NathanaelRea changed the title Add docker compose feat: Add docker compose Jan 25, 2025
@NathanaelRea
Copy link
Author

NathanaelRea commented Jan 25, 2025

Also I noticed that currently the mysql start-database.sh file uses postgres for the container name. Should I fix it here or create a separate PR?

https://github.com/t3-oss/create-t3-app/blob/main/cli/template/extras/start-database/mysql.sh#L18

Edit:

I realized a couple things to simplify this change and the container overall. Let me know if I should make them.

  1. Remove redundant checks inside start-database.sh Link to lines since with docker compose, it will tell you these errors directly
  2. Remove DB_CONTAINER_NAME. Then if it's no longer needed in start-database.sh It could just be put in the docker-compose itself, like so:
services:
db:
  image: postgres:latest
  container_name: "${DB_NAME?}-postgres"
or even provider agnostic "t3-db"
  1. Now all start-database.sh are the same, so we could move it to /cli/template/extras/docker instead of /docker/db-subdir which is better for the future if it can be used as an entrypoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant