forked from strapi/strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker-compose.dev file to easily work with different databases i…
…n dev mode Signed-off-by: Alexandre Bodin <[email protected]> Remove old files not used anymore Signed-off-by: Alexandre Bodin <[email protected]> Added info about conflict with local db instances and how to change port configurations Signed-off-by: Alexandre Bodin <[email protected]> Fix typos Signed-off-by: Alexandre Bodin <[email protected]>
- Loading branch information
1 parent
67187c3
commit f7a8d06
Showing
5 changed files
with
123 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: '3' | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
restart: always | ||
volumes: | ||
- pgdata:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_USER: strapi | ||
POSTGRES_PASSWORD: strapi | ||
POSTGRES_DB: strapi | ||
ports: | ||
- '5432:5432' | ||
|
||
mongo: | ||
image: mongo | ||
restart: always | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: root | ||
MONGO_INITDB_ROOT_PASSWORD: strapi | ||
volumes: | ||
- mongodata:/data/db | ||
ports: | ||
- '27017:27017' | ||
|
||
mysql: | ||
image: mysql | ||
restart: always | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
MYSQL_DATABASE: strapi | ||
MYSQL_USER: strapi | ||
MYSQL_PASSWORD: strapi | ||
MYSQL_ROOT_HOST: '%' | ||
MYSQL_ROOT_PASSWORD: strapi | ||
volumes: | ||
- mysqldata:/var/lib/mysql | ||
ports: | ||
- '3306:3306' | ||
|
||
volumes: | ||
pgdata: | ||
mongodata: | ||
mysqldata: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,80 @@ | ||
# getstarted | ||
|
||
A quick description of getstarted. | ||
This is an example app you can run to test your changes quickly. | ||
|
||
Start the app with mongo | ||
## Requirements | ||
|
||
`DB=mongo yarn develop` | ||
- Docker | ||
- Docker compose | ||
- Node | ||
|
||
## Installation | ||
|
||
By default once you have setup the monorepo you will be able to run the getstarted app with a sqlite DB directly. | ||
|
||
If you wish to run the getstarted app with another database you can use the `docker-compose.dev.yml` file at the root of the directory. | ||
|
||
### start the databases | ||
|
||
Run the following command at the root of the monorepo | ||
|
||
``` | ||
docker-compose -f docker-compose.dev.yml up -d | ||
``` | ||
|
||
If you need to stop the running databases you can stop them with the following command: | ||
|
||
``` | ||
docker-compose -f docker-compose.dev.yml stop | ||
``` | ||
|
||
### run the getstarted app with a specific database | ||
|
||
``` | ||
DB={dbName} yarn develop | ||
``` | ||
|
||
The way it works is that the `getstarted` app has a specific `database.js` config file that will use the `DB` environment variable to setup the right database connection. You can look at the code [here](./config/environments/development/database.js) | ||
|
||
**Warning** | ||
|
||
You might have some errors while connecting to the databases. | ||
They might be coming from a conflict between a locally running database instance and the docker instance. To avoid the errors either shutdown your local database instance or change the ports in the `./config/environments/development/database.js` and the `docker-compose.dev.yml` file. | ||
|
||
**Example**: | ||
|
||
`database.js` | ||
|
||
```js | ||
module.exports = { | ||
connections: { | ||
default: { | ||
connector: 'mongoose', | ||
settings: { | ||
// host: 'localhost', | ||
// database: 'strapi', | ||
// username: 'root', | ||
// password: 'strapi', | ||
port: 27099, | ||
}, | ||
options: {}, | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
`docker-compose.dev.yml` | ||
|
||
```yml | ||
services: | ||
mongo: | ||
# image: mongo | ||
# restart: always | ||
# environment: | ||
# MONGO_INITDB_ROOT_USERNAME: root | ||
# MONGO_INITDB_ROOT_PASSWORD: strapi | ||
# volumes: | ||
# - mongodata:/data/db | ||
ports: | ||
- '27099:27017' | ||
``` |
This file was deleted.
Oops, something went wrong.