create-directus-docker 1.6.3 → 1.6.4

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
- # Docker with Directus + MySQL + Adminer + GraphiQL
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
- ## Requirements
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
- ## Seeding MySQL data
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
- 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, BEFORE you run all services. MySQL will run any files in this directory the first time it launches.
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.3",
4
+ "version": "1.6.4",
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,152 @@
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
+ - conf:/etc/nginx/conf.d
14
+ - vhost:/etc/nginx/vhost.d
15
+ - html:/usr/share/nginx/html
16
+ - certs:/etc/nginx/certs:ro
17
+ networks:
18
+ - directus
19
+
20
+ acme-companion:
21
+ image: nginxproxy/acme-companion
22
+ container_name: nginx-proxy-acme
23
+ restart: always
24
+ depends_on:
25
+ - nginx-proxy
26
+ environment:
27
+ DEFAULT_EMAIL: ${ADMIN_EMAIL}
28
+ NGINX_PROXY_CONTAINER: nginx-proxy
29
+ volumes:
30
+ - conf:/etc/nginx/conf.d
31
+ - vhost:/etc/nginx/vhost.d
32
+ - html:/usr/share/nginx/html
33
+ - certs:/etc/nginx/certs:rw
34
+ - acme:/etc/acme.sh
35
+ - /var/run/docker.sock:/var/run/docker.sock:ro
36
+ networks:
37
+ - directus
38
+
39
+ mysql:
40
+ container_name: mysql
41
+ image: mysql:9.0.1
42
+ restart: always
43
+ healthcheck:
44
+ test: ['CMD', 'mysqladmin', 'ping', '--silent']
45
+ interval: 5s
46
+ timeout: 20s
47
+ retries: 3
48
+ start_period: 5s
49
+ networks:
50
+ - directus
51
+ ports:
52
+ - 3306:3306
53
+ volumes:
54
+ - ./mysql:/var/lib/mysql
55
+ - ./init:/docker-entrypoint-initdb.d
56
+ # command: --mysql-native-password=ON
57
+ environment:
58
+ MYSQL_USER: ${MYSQL_USER}
59
+ MYSQL_PASSWORD: ${MYSQL_PASS}
60
+ MYSQL_DATABASE: ${MYSQL_DB}
61
+ MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
62
+
63
+ adminer:
64
+ container_name: adminer
65
+ image: adminer:latest
66
+ restart: always
67
+ depends_on:
68
+ mysql:
69
+ condition: service_healthy
70
+ cache:
71
+ condition: service_healthy
72
+ networks:
73
+ - directus
74
+ environment:
75
+ ADMINER_DEFAULT_SERVER: mysql
76
+ ports:
77
+ - 8080:8080
78
+
79
+ cache:
80
+ container_name: cache
81
+ image: redis:6.2.6
82
+ healthcheck:
83
+ test: ["CMD-SHELL", "[ $$(redis-cli ping) = 'PONG' ]"]
84
+ interval: 10s
85
+ timeout: 5s
86
+ retries: 5
87
+ start_interval: 5s
88
+ start_period: 30s
89
+ networks:
90
+ - directus
91
+
92
+ directus:
93
+ container_name: directus
94
+ image: directus/directus:11.1.1
95
+ restart: always
96
+ ports:
97
+ - ${DIRECTUS_PORT}:8055
98
+ expose:
99
+ - 8055
100
+ volumes:
101
+ - ./directus/uploads:/directus/uploads
102
+ - ./snapshots:/directus/snapshots
103
+ networks:
104
+ - directus
105
+ depends_on:
106
+ mysql:
107
+ condition: service_healthy
108
+ cache:
109
+ condition: service_healthy
110
+ environment:
111
+ KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
112
+ SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'
113
+ DB_CLIENT: 'mysql'
114
+ DB_HOST: 'mysql'
115
+ DB_USER: ${MYSQL_USER}
116
+ DB_PASSWORD: ${MYSQL_PASS}
117
+ DB_DATABASE: ${MYSQL_DB}
118
+ DB_PORT: '3306'
119
+
120
+ VIRTUAL_HOST: ${VIRTUAL_HOST}
121
+ VIRTUAL_PORT: ${DIRECTUS_PORT}
122
+ LETSENCRYPT_HOST: ${VIRTUAL_HOST}
123
+ LETSENCRYPT_EMAIL: ${CERT_EMAIL}
124
+
125
+ CACHE_ENABLED: 'true'
126
+ CACHE_STORE: 'redis'
127
+ REDIS: 'redis://cache:6379'
128
+ CACHE_AUTO_PURGE: 'true'
129
+ CACHE_SYSTEM_TTL: '2m'
130
+ CACHE_SCHEMA: 'false'
131
+ ADMIN_EMAIL: ${ADMIN_EMAIL}
132
+ ADMIN_PASSWORD: ${ADMIN_PASSWORD}
133
+ CORS_ENABLED: 'true'
134
+ CORS_ORIGIN: 'true'
135
+
136
+ # uncomment the following lines to enable email verification
137
+ EMAIL_VERIFY_SETUP: 'true'
138
+ EMAIL_TRANSPORT: ${EMAIL_TRANSPORT}
139
+ EMAIL_SENDGRID_API_KEY: ${EMAIL_SENDGRID_API_KEY}
140
+ EMAIL_FROM: ${EMAIL_FROM}
141
+
142
+ PUBLIC_URL: ${PUBLIC_URL}
143
+
144
+ networks:
145
+ directus:
146
+ driver: bridge
147
+ volumes:
148
+ conf:
149
+ vhost:
150
+ html:
151
+ certs:
152
+ 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"