-
Notifications
You must be signed in to change notification settings - Fork 2
Description
dev can use docker to provision a database for a project. It can read the configuration from either package.json or a dedicated dev.json file. dev up can download the image and start the container and dev down can stop the container. There can be recipes for different docker images.
package.json with configuration
{
"dev": {
"docker": [{
"image": "postgres:13",
"port": 5432,
"env": {
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "password",
"POSTGRES_DB": "postgres"
}
}]
}
}or use recipes:
dev.json with configuration
{
"dev": {
"docker": [{
"recipe": "postgres"
}]
}
}I think the package.json approach is more like using docker-compose. The dev.json approach is cleaner.
There can be a dev command to add recipes to the dev.json file.
dev services add postgres
On the dev side, dev automatically populates the require environment variables for the project to connect to the database. It can also provide a URL for the database.
This could be the case only when you cd into the project directory. It can also provide a command to connect to the database like dev services connect postgres.
dev services list could list all the services running for the project.
An option to export the configuration to a docker-compose.yml file would be nice dev services export docker-compose > docker-compose.yml.
Also the user should be able to export the environment variables dev services export env > .env.
dev can also provide a way to run commands in the container like dev services exec postgres psql -U postgres.
Some othre useful things:
dev services logs <filters>dev services stop postgresdev services start postgresdev services restart postgresdev services rm postgresdev services prune
Of course this can also be done with docker-compose but dev can provide a more user-friendly interface and can be more integrated with the project via setting the environment variables and providing a way to connect to the database. It can also provide a way to manage the services for multiple projects.