Skip to content

Commit

Permalink
Add docker-compose.dev file to easily work with different databases i…
Browse files Browse the repository at this point in the history
…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
alexandrebodin committed Mar 30, 2020
1 parent 67187c3 commit f7a8d06
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 103 deletions.
11 changes: 2 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,9 @@ cd strapi && yarn setup

#### 4. Start the example application

**Go to the getstarted application**
Read the `getstarted` application README [here](./examples/getstarted/README.md).

```bash
cd strapi/examples/getstarted
yarn develop
```

The server (API) is available at http://localhost:1337

The built administration panel is available at http://localhost:1337/admin
#### 5. Running the administration panel in development mode

**Start the administration panel server for development**

Expand Down
17 changes: 0 additions & 17 deletions Makefile

This file was deleted.

45 changes: 45 additions & 0 deletions docker-compose.dev.yml
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:
79 changes: 76 additions & 3 deletions examples/getstarted/README.md
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'
```
74 changes: 0 additions & 74 deletions mkdocs.yml

This file was deleted.

0 comments on commit f7a8d06

Please sign in to comment.