create-directus-docker 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
## Docker with Directus / MySQL / Adminer / GraphQL
|
|
2
2
|
|
|
3
|
-
A quick-start installer and launcher for Docker compose, containing Directus with MySQL, an Adminer UI for managing the database, and a GraphiQL playground. Plus a helper app to walk you through initializing environment variables and launching all services.
|
|
3
|
+
A quick-start installer and launcher for Docker compose, containing Directus with MySQL, an Adminer UI for managing the database, and a GraphiQL playground. Plus a helper app to walk you through initializing environment variables and launching all services.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
You need [Docker](https://www.docker.com) and [Node](https://nodejs.org) installed on your machine:
|
|
5
|
+
**Requirements:** you need [Docker](https://www.docker.com) and [Node](https://nodejs.org) installed on your machine:
|
|
8
6
|
|
|
9
7
|
- [Install Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
|
10
8
|
- [Install Node](https://nodejs.org/en/download/)
|
|
11
9
|
|
|
12
10
|
## Installation & Usage
|
|
13
11
|
|
|
12
|
+
**The easiest way to get up and running is to open a terminal session and run:**
|
|
13
|
+
|
|
14
14
|
```bash
|
|
15
15
|
npx create-directus-docker@latest <my-project>
|
|
16
16
|
```
|
|
@@ -25,15 +25,61 @@ npm start
|
|
|
25
25
|
|
|
26
26
|
The wizard will walk you through configuring your environment variables, and will launch all services for you.
|
|
27
27
|
|
|
28
|
+
### Seeding MySQL data
|
|
29
|
+
|
|
30
|
+
If you want to seed your database with data on first launch, place your .sql file(s) in the "init" directory at the root of this package. MySQL will run any files in this directory the first time it launches.
|
|
31
|
+
|
|
32
|
+
### Starting/stopping with Docker Compose
|
|
33
|
+
|
|
34
|
+
To **stop** your running containers, simply run `docker compose down` in your terminal from within the project directory. All containers will be stopped.
|
|
35
|
+
|
|
36
|
+
To **restart** your stopped containers, you can let the helper app do it for you:
|
|
37
|
+
|
|
38
|
+
`npm start`
|
|
39
|
+
|
|
40
|
+
Or you can follow this sequence:
|
|
41
|
+
|
|
42
|
+
`docker compose up mysql -d`
|
|
43
|
+
|
|
44
|
+
Then wait 10-20 seconds (for MySQL to boot), then type:
|
|
45
|
+
|
|
46
|
+
`docker compose up -d`
|
|
47
|
+
|
|
28
48
|
**Boom!** You're done. Now you can access the URLS from here:
|
|
29
49
|
|
|
30
50
|
Directus CMS: http://localhost:8055
|
|
31
|
-
Adminer (for MySQL): http://localhost:8080
|
|
32
51
|
Apollo GraphQL Sandbox: https://studio.apollographql.com/sandbox/explorer?endpoint=http://localhost:8055/graphql
|
|
52
|
+
Adminer (for MySQL): http://localhost:8080
|
|
53
|
+
|
|
54
|
+
**Check on running containers:**
|
|
55
|
+
|
|
56
|
+
Simply run `docker compose ps` to see the status of running containers. Or, run `docker compose ps -a` to see all containers, running or not.
|
|
57
|
+
|
|
58
|
+
### NGINX Proxy example
|
|
59
|
+
|
|
60
|
+
Included in this package is also a `docker-compose-nginx.yml` file that demonstrates how to run a reverse proxy on a Linux-based server so that you can use a custom domain with an auto-generated/renewed SSL certificate via Let's Encrypt.
|
|
33
61
|
|
|
34
|
-
|
|
62
|
+
To use this, rename the existing `docker-compose.yml` file to something else, and rename the `docker-compose-nginx.yml` to `docker-compose.yml`.
|
|
35
63
|
|
|
36
|
-
|
|
64
|
+
Add the following env variables to your `.env` file:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
VIRTUAL_HOST="your-domain.com"
|
|
68
|
+
CERT_EMAIL="you@email"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
and make sure your Directus .env variables look something like this:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
DIRECTUS_DOMAIN="localhost"
|
|
75
|
+
DIRECTUS_PORT="8055"
|
|
76
|
+
PUBLIC_URL="https://your-domain.com"
|
|
77
|
+
API_ENDPOINT="https://your-domain.com/graphql"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Lastly, before running `npm start`, make sure you have pointed to your domain's DNS to your server using the appropriate A records.
|
|
81
|
+
|
|
82
|
+
Note: you may need to adjust or disable your firewall before running this, to ensure that the SSL certificate can be properly generated using the included `acme-companion` container for Let's Encrypt.
|
|
37
83
|
|
|
38
84
|
### Snapshot the Data Model
|
|
39
85
|
|
|
@@ -57,22 +103,8 @@ By applying the snapshot, Directus will auto-detect the changes required to make
|
|
|
57
103
|
|
|
58
104
|
`npm run snapshot-test --snapshot=snapshot-file.yaml`
|
|
59
105
|
|
|
60
|
-
## Starting/stopping with Docker Compose
|
|
61
|
-
|
|
62
|
-
To **stop** your running containers, simply run either `npm run stop` or `docker compose down` from within the project directory. All containers will be stopped.
|
|
63
|
-
|
|
64
|
-
To **restart** your stopped containers, you can let the helper app do it for you:
|
|
65
|
-
|
|
66
|
-
`npm start`
|
|
67
|
-
|
|
68
|
-
The helper app waits for MySQL to be ready before starting the rest of the services (otherwise, you'd get errors).
|
|
69
|
-
|
|
70
|
-
**Check on running containers:**
|
|
71
|
-
|
|
72
|
-
Simply run `docker compose ps` to see the status of running containers. Or, run `docker compose ps -a` to see all containers, running or not.
|
|
73
|
-
|
|
74
106
|
### Examples of getting an auth token for Directus API:
|
|
75
107
|
|
|
76
108
|
curl -X POST localhost:8055/auth/login -H 'Content-Type: application/json' -d '{"email":"you@email.com","password":"your-password"}'
|
|
77
109
|
|
|
78
|
-
curl -X POST localhost:8055/auth/refresh -H 'Content-Type: application/json' -d '{"refresh_token": "W5L70MBXKElx5ZVZwxmQVG8qdVjukiRVIwD5FYG7tCPyyuCM_I3IyCsYnFhMUrRi", "mode": "json"}'
|
|
110
|
+
curl -X POST localhost:8055/auth/refresh -H 'Content-Type: application/json' -d '{"refresh_token": "W5L70MBXKElx5ZVZwxmQVG8qdVjukiRVIwD5FYG7tCPyyuCM_I3IyCsYnFhMUrRi", "mode": "json"}'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-directus-docker",
|
|
3
3
|
"description": "An installer for Dockerized Directus + MySQL + Adminer + GraphQL Sandbox with a helper Node app",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Dave Kobrenski",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"init": "npm-run-all -p copy:*",
|
|
27
27
|
"copy:package": "copy-file ../directus-mysql-template/package.json ./templates/default/package.json",
|
|
28
|
+
"copy:env-sample": "copy-file ../directus-mysql-template/env-sample.txt ./templates/default/env-sample.txt",
|
|
28
29
|
"copy:compose": "copy-file ../directus-mysql-template/docker-compose.yml ./templates/default/docker-compose.yml",
|
|
30
|
+
"copy:compose-nginx": "copy-file ../directus-mysql-template/docker-compose-nginx.yml ./templates/default/docker-compose-nginx.yml",
|
|
29
31
|
"copy:readme": "copy-file ../directus-mysql-template/README.md ./templates/default/README.md",
|
|
30
32
|
"copy:lib": "copyfiles --flat ../directus-mysql-template/lib/*.js ./templates/default/lib"
|
|
31
33
|
},
|
|
@@ -41,28 +41,6 @@ As an alternative, you can install this package by following these steps. Once y
|
|
|
41
41
|
|
|
42
42
|
If you want to seed your database with data on first launch, place your .sql file(s) in the "init" directory at the root of this package. MySQL will run any files in this directory the first time it launches.
|
|
43
43
|
|
|
44
|
-
### Snapshot the Data Model
|
|
45
|
-
|
|
46
|
-
Directus can automatically generate a snapshot of your current data model in YAML format. This includes all collections, fields, and relations, and their configuration. This snapshot can be checked in version control and shared with your team. To generate the snapshot, run:
|
|
47
|
-
|
|
48
|
-
`npm run snapshot`
|
|
49
|
-
|
|
50
|
-
The 'directus' container **must be running** in order to take a snapshot.
|
|
51
|
-
|
|
52
|
-
### Apply a Snapshot
|
|
53
|
-
|
|
54
|
-
To overwrite the current Directus instance with the data model specified in that snapshot, you can apply a snapshot by running:
|
|
55
|
-
|
|
56
|
-
`npm run snapshot-apply --snapshot=snapshot-file.yaml`
|
|
57
|
-
|
|
58
|
-
Change the name of the file in the command to match an actual snapshot file in your 'snapshots' directory.
|
|
59
|
-
|
|
60
|
-
By applying the snapshot, Directus will auto-detect the changes required to make the current instance up to date with the proposed data model in the snapshot file, and will run the required migrations to the database to make it match the snapshot. This is useful when migrating to/from another directus instance.
|
|
61
|
-
|
|
62
|
-
**It is recommended that you test this first by doing a dry-run like this:**
|
|
63
|
-
|
|
64
|
-
`npm run snapshot-test --snapshot=snapshot-file.yaml`
|
|
65
|
-
|
|
66
44
|
### Starting/stopping with Docker Compose
|
|
67
45
|
|
|
68
46
|
To **stop** your running containers, simply run `docker compose down` in your terminal from within the project directory. All containers will be stopped.
|
|
@@ -89,6 +67,54 @@ Adminer (for MySQL): http://localhost:8080
|
|
|
89
67
|
|
|
90
68
|
Simply run `docker compose ps` to see the status of running containers. Or, run `docker compose ps -a` to see all containers, running or not.
|
|
91
69
|
|
|
70
|
+
### NGINX Proxy example
|
|
71
|
+
|
|
72
|
+
Included in this package is also a `docker-compose-nginx.yml` file that demonstrates how to run a reverse proxy on a Linux-based server so that you can use a custom domain with an auto-generated/renewed SSL certificate via Let's Encrypt.
|
|
73
|
+
|
|
74
|
+
To use this, rename the existing `docker-compose.yml` file to something else, and rename the `docker-compose-nginx.yml` to `docker-compose.yml`.
|
|
75
|
+
|
|
76
|
+
Add the following env variables to your `.env` file:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
VIRTUAL_HOST="your-domain.com"
|
|
80
|
+
CERT_EMAIL="you@email"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
and make sure your Directus .env variables look something like this:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
DIRECTUS_DOMAIN="localhost"
|
|
87
|
+
DIRECTUS_PORT="8055"
|
|
88
|
+
PUBLIC_URL="https://your-domain.com"
|
|
89
|
+
API_ENDPOINT="https://your-domain.com/graphql"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Lastly, before running `npm start`, make sure you have pointed to your domain's DNS to your server using the appropriate A records.
|
|
93
|
+
|
|
94
|
+
Note: you may need to adjust or disable your firewall before running this, to ensure that the SSL certificate can be properly generated using the included `acme-companion` container for Let's Encrypt.
|
|
95
|
+
|
|
96
|
+
### Snapshot the Data Model
|
|
97
|
+
|
|
98
|
+
Directus can automatically generate a snapshot of your current data model in YAML format. This includes all collections, fields, and relations, and their configuration. This snapshot can be checked in version control and shared with your team. To generate the snapshot, run:
|
|
99
|
+
|
|
100
|
+
`npm run snapshot`
|
|
101
|
+
|
|
102
|
+
The 'directus' container **must be running** in order to take a snapshot.
|
|
103
|
+
|
|
104
|
+
### Apply a Snapshot
|
|
105
|
+
|
|
106
|
+
To overwrite the current Directus instance with the data model specified in that snapshot, you can apply a snapshot by running:
|
|
107
|
+
|
|
108
|
+
`npm run snapshot-apply --snapshot=snapshot-file.yaml`
|
|
109
|
+
|
|
110
|
+
Change the name of the file in the command to match an actual snapshot file in your 'snapshots' directory.
|
|
111
|
+
|
|
112
|
+
By applying the snapshot, Directus will auto-detect the changes required to make the current instance up to date with the proposed data model in the snapshot file, and will run the required migrations to the database to make it match the snapshot. This is useful when migrating to/from another directus instance.
|
|
113
|
+
|
|
114
|
+
**It is recommended that you test this first by doing a dry-run like this:**
|
|
115
|
+
|
|
116
|
+
`npm run snapshot-test --snapshot=snapshot-file.yaml`
|
|
117
|
+
|
|
92
118
|
### Examples of getting an auth token for Directus API:
|
|
93
119
|
|
|
94
120
|
curl -X POST localhost:8055/auth/login -H 'Content-Type: application/json' -d '{"email":"you@email.com","password":"your-password"}'
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
services:
|
|
2
|
+
nginx-proxy:
|
|
3
|
+
image: nginxproxy/nginx-proxy
|
|
4
|
+
container_name: nginx-proxy
|
|
5
|
+
restart: always
|
|
6
|
+
labels:
|
|
7
|
+
- com.github.nginx-proxy.nginx
|
|
8
|
+
ports:
|
|
9
|
+
- "80:80"
|
|
10
|
+
- "443:443"
|
|
11
|
+
volumes:
|
|
12
|
+
- /var/run/docker.sock:/tmp/docker.sock:ro
|
|
13
|
+
- ./custom_proxy_settings.conf:/etc/nginx/conf.d/custom_proxy_settings.conf
|
|
14
|
+
- conf:/etc/nginx/conf.d
|
|
15
|
+
- vhost:/etc/nginx/vhost.d
|
|
16
|
+
- html:/usr/share/nginx/html
|
|
17
|
+
- certs:/etc/nginx/certs:ro
|
|
18
|
+
networks:
|
|
19
|
+
- directus
|
|
20
|
+
|
|
21
|
+
acme-companion:
|
|
22
|
+
image: nginxproxy/acme-companion
|
|
23
|
+
container_name: nginx-proxy-acme
|
|
24
|
+
restart: always
|
|
25
|
+
depends_on:
|
|
26
|
+
- nginx-proxy
|
|
27
|
+
environment:
|
|
28
|
+
DEFAULT_EMAIL: ${ADMIN_EMAIL}
|
|
29
|
+
NGINX_PROXY_CONTAINER: nginx-proxy
|
|
30
|
+
volumes:
|
|
31
|
+
- conf:/etc/nginx/conf.d
|
|
32
|
+
- vhost:/etc/nginx/vhost.d
|
|
33
|
+
- html:/usr/share/nginx/html
|
|
34
|
+
- certs:/etc/nginx/certs:rw
|
|
35
|
+
- acme:/etc/acme.sh
|
|
36
|
+
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
37
|
+
networks:
|
|
38
|
+
- directus
|
|
39
|
+
|
|
40
|
+
mysql:
|
|
41
|
+
container_name: mysql
|
|
42
|
+
image: mysql:9.0.1
|
|
43
|
+
restart: always
|
|
44
|
+
healthcheck:
|
|
45
|
+
test: ['CMD', 'mysqladmin', 'ping', '--silent']
|
|
46
|
+
interval: 5s
|
|
47
|
+
timeout: 20s
|
|
48
|
+
retries: 3
|
|
49
|
+
start_period: 5s
|
|
50
|
+
networks:
|
|
51
|
+
- directus
|
|
52
|
+
ports:
|
|
53
|
+
- 3306:3306
|
|
54
|
+
volumes:
|
|
55
|
+
- ./mysql:/var/lib/mysql
|
|
56
|
+
- ./init:/docker-entrypoint-initdb.d
|
|
57
|
+
# command: --mysql-native-password=ON
|
|
58
|
+
environment:
|
|
59
|
+
MYSQL_USER: ${MYSQL_USER}
|
|
60
|
+
MYSQL_PASSWORD: ${MYSQL_PASS}
|
|
61
|
+
MYSQL_DATABASE: ${MYSQL_DB}
|
|
62
|
+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
|
|
63
|
+
|
|
64
|
+
adminer:
|
|
65
|
+
container_name: adminer
|
|
66
|
+
image: adminer:latest
|
|
67
|
+
restart: always
|
|
68
|
+
depends_on:
|
|
69
|
+
mysql:
|
|
70
|
+
condition: service_healthy
|
|
71
|
+
cache:
|
|
72
|
+
condition: service_healthy
|
|
73
|
+
networks:
|
|
74
|
+
- directus
|
|
75
|
+
environment:
|
|
76
|
+
ADMINER_DEFAULT_SERVER: mysql
|
|
77
|
+
ports:
|
|
78
|
+
- 8080:8080
|
|
79
|
+
|
|
80
|
+
cache:
|
|
81
|
+
container_name: cache
|
|
82
|
+
image: redis:6.2.6
|
|
83
|
+
healthcheck:
|
|
84
|
+
test: ["CMD-SHELL", "[ $$(redis-cli ping) = 'PONG' ]"]
|
|
85
|
+
interval: 10s
|
|
86
|
+
timeout: 5s
|
|
87
|
+
retries: 5
|
|
88
|
+
start_interval: 5s
|
|
89
|
+
start_period: 30s
|
|
90
|
+
networks:
|
|
91
|
+
- directus
|
|
92
|
+
|
|
93
|
+
directus:
|
|
94
|
+
container_name: directus
|
|
95
|
+
image: directus/directus:11.1.1
|
|
96
|
+
restart: always
|
|
97
|
+
ports:
|
|
98
|
+
- ${DIRECTUS_PORT}:8055
|
|
99
|
+
expose:
|
|
100
|
+
- 8055
|
|
101
|
+
volumes:
|
|
102
|
+
- ./directus/uploads:/directus/uploads
|
|
103
|
+
- ./snapshots:/directus/snapshots
|
|
104
|
+
networks:
|
|
105
|
+
- directus
|
|
106
|
+
depends_on:
|
|
107
|
+
mysql:
|
|
108
|
+
condition: service_healthy
|
|
109
|
+
cache:
|
|
110
|
+
condition: service_healthy
|
|
111
|
+
environment:
|
|
112
|
+
KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
|
|
113
|
+
SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'
|
|
114
|
+
DB_CLIENT: 'mysql'
|
|
115
|
+
DB_HOST: 'mysql'
|
|
116
|
+
DB_USER: ${MYSQL_USER}
|
|
117
|
+
DB_PASSWORD: ${MYSQL_PASS}
|
|
118
|
+
DB_DATABASE: ${MYSQL_DB}
|
|
119
|
+
DB_PORT: '3306'
|
|
120
|
+
|
|
121
|
+
VIRTUAL_HOST: ${VIRTUAL_HOST}
|
|
122
|
+
VIRTUAL_PORT: ${DIRECTUS_PORT}
|
|
123
|
+
LETSENCRYPT_HOST: ${VIRTUAL_HOST}
|
|
124
|
+
LETSENCRYPT_EMAIL: ${CERT_EMAIL}
|
|
125
|
+
|
|
126
|
+
CACHE_ENABLED: 'true'
|
|
127
|
+
CACHE_STORE: 'redis'
|
|
128
|
+
REDIS: 'redis://cache:6379'
|
|
129
|
+
CACHE_AUTO_PURGE: 'true'
|
|
130
|
+
CACHE_SYSTEM_TTL: '2m'
|
|
131
|
+
CACHE_SCHEMA: 'false'
|
|
132
|
+
ADMIN_EMAIL: ${ADMIN_EMAIL}
|
|
133
|
+
ADMIN_PASSWORD: ${ADMIN_PASSWORD}
|
|
134
|
+
CORS_ENABLED: 'true'
|
|
135
|
+
CORS_ORIGIN: 'true'
|
|
136
|
+
FILES_MAX_UPLOAD_SIZE: '10mb'
|
|
137
|
+
MAX_PAYLOAD_SIZE: '10mb'
|
|
138
|
+
|
|
139
|
+
# uncomment the following lines to enable email verification
|
|
140
|
+
EMAIL_VERIFY_SETUP: 'true'
|
|
141
|
+
EMAIL_TRANSPORT: ${EMAIL_TRANSPORT}
|
|
142
|
+
EMAIL_SENDGRID_API_KEY: ${EMAIL_SENDGRID_API_KEY}
|
|
143
|
+
EMAIL_FROM: ${EMAIL_FROM}
|
|
144
|
+
|
|
145
|
+
PUBLIC_URL: ${PUBLIC_URL}
|
|
146
|
+
|
|
147
|
+
networks:
|
|
148
|
+
directus:
|
|
149
|
+
driver: bridge
|
|
150
|
+
volumes:
|
|
151
|
+
conf:
|
|
152
|
+
vhost:
|
|
153
|
+
html:
|
|
154
|
+
certs:
|
|
155
|
+
acme:
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# This is a sample .env file with all possible options
|
|
2
|
+
|
|
3
|
+
# Email and password to login to Directus:
|
|
4
|
+
ADMIN_EMAIL="you@email"
|
|
5
|
+
ADMIN_PASSWORD="s0mEpa55w0rd"
|
|
6
|
+
|
|
7
|
+
# Define the mysql user name and password:
|
|
8
|
+
MYSQL_USER="admin"
|
|
9
|
+
MYSQL_PASS="s0mEpa55w0rd"
|
|
10
|
+
|
|
11
|
+
# Give your database a name:
|
|
12
|
+
MYSQL_DB="directus"
|
|
13
|
+
|
|
14
|
+
# Set a root password for MySQL to something secure:
|
|
15
|
+
MYSQL_ROOT_PASS="s0mEpa55w0rd"
|
|
16
|
+
|
|
17
|
+
# Set the domain for directus to use:
|
|
18
|
+
# eg, https://mydomain.com
|
|
19
|
+
# in local dev environments, just leave it set to localhost:port
|
|
20
|
+
DIRECTUS_DOMAIN="localhost"
|
|
21
|
+
DIRECTUS_PORT="8055"
|
|
22
|
+
PUBLIC_URL="https://your-domain.com"
|
|
23
|
+
API_ENDPOINT="https://your-domain.com/graphql"
|
|
24
|
+
|
|
25
|
+
EMAIL_TRANSPORT="sendgrid"
|
|
26
|
+
EMAIL_SENDGRID_API_KEY="your-send-grid-api-key"
|
|
27
|
+
EMAIL_FROM="you@email"
|
|
28
|
+
|
|
29
|
+
# for use with the nginx proxy version:
|
|
30
|
+
VIRTUAL_HOST="your-domain.com"
|
|
31
|
+
CERT_EMAIL="you@email"
|