create-directus-docker 1.5.7 → 1.6.0
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-directus-docker",
|
|
3
|
-
"description": "An installer for Dockerized Directus + MySQL + Adminer +
|
|
4
|
-
"version": "1.
|
|
3
|
+
"description": "An installer for Dockerized Directus + MySQL + Adminer + GraphQL Sandbox with a helper Node app",
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Dave Kobrenski",
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
version: '3'
|
|
2
|
-
|
|
3
1
|
services:
|
|
4
2
|
|
|
5
3
|
mysql:
|
|
6
4
|
container_name: mysql
|
|
7
|
-
image: mysql:8
|
|
5
|
+
image: mysql:8.4.2
|
|
8
6
|
restart: always
|
|
9
7
|
healthcheck:
|
|
10
8
|
test: ['CMD', 'mysqladmin', 'ping', '--silent']
|
|
@@ -19,7 +17,7 @@ services:
|
|
|
19
17
|
volumes:
|
|
20
18
|
- ./mysql:/var/lib/mysql
|
|
21
19
|
- ./init:/docker-entrypoint-initdb.d
|
|
22
|
-
command: --
|
|
20
|
+
command: --mysql-native-password=ON
|
|
23
21
|
environment:
|
|
24
22
|
MYSQL_USER: ${MYSQL_USER}
|
|
25
23
|
MYSQL_PASSWORD: ${MYSQL_PASS}
|
|
@@ -31,7 +29,10 @@ services:
|
|
|
31
29
|
image: adminer:latest
|
|
32
30
|
restart: always
|
|
33
31
|
depends_on:
|
|
34
|
-
|
|
32
|
+
mysql:
|
|
33
|
+
condition: service_healthy
|
|
34
|
+
cache:
|
|
35
|
+
condition: service_healthy
|
|
35
36
|
networks:
|
|
36
37
|
- directus
|
|
37
38
|
environment:
|
|
@@ -41,7 +42,14 @@ services:
|
|
|
41
42
|
|
|
42
43
|
cache:
|
|
43
44
|
container_name: cache
|
|
44
|
-
image: redis:6
|
|
45
|
+
image: redis:6.2.6
|
|
46
|
+
healthcheck:
|
|
47
|
+
test: ["CMD-SHELL", "[ $$(redis-cli ping) = 'PONG' ]"]
|
|
48
|
+
interval: 10s
|
|
49
|
+
timeout: 5s
|
|
50
|
+
retries: 5
|
|
51
|
+
start_interval: 5s
|
|
52
|
+
start_period: 30s
|
|
45
53
|
networks:
|
|
46
54
|
- directus
|
|
47
55
|
|
|
@@ -57,8 +65,10 @@ services:
|
|
|
57
65
|
networks:
|
|
58
66
|
- directus
|
|
59
67
|
depends_on:
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
mysql:
|
|
69
|
+
condition: service_healthy
|
|
70
|
+
cache:
|
|
71
|
+
condition: service_healthy
|
|
62
72
|
environment:
|
|
63
73
|
KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
|
|
64
74
|
SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'
|
|
@@ -80,19 +90,13 @@ services:
|
|
|
80
90
|
CORS_ENABLED: 'true'
|
|
81
91
|
CORS_ORIGIN: 'true'
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
# uncomment the following lines to enable email verification
|
|
94
|
+
# EMAIL_VERIFY_SETUP: 'true'
|
|
95
|
+
# EMAIL_TRANSPORT: ${EMAIL_TRANSPORT}
|
|
96
|
+
# EMAIL_SENDGRID_API_KEY: ${EMAIL_SENDGRID_API_KEY}
|
|
97
|
+
# EMAIL_FROM: ${EMAIL_FROM}
|
|
84
98
|
|
|
85
|
-
|
|
86
|
-
container_name: graphiql
|
|
87
|
-
image: plutoz/graphiql
|
|
88
|
-
depends_on:
|
|
89
|
-
- directus
|
|
90
|
-
ports:
|
|
91
|
-
- 4000:4000
|
|
92
|
-
environment:
|
|
93
|
-
API_ENDPOINT: ${API_ENDPOINT}
|
|
94
|
-
networks:
|
|
95
|
-
- directus
|
|
99
|
+
PUBLIC_URL: ${PUBLIC_URL}
|
|
96
100
|
|
|
97
101
|
networks:
|
|
98
102
|
directus:
|
|
@@ -58,13 +58,13 @@ try {
|
|
|
58
58
|
|
|
59
59
|
if (fs.existsSync(path.join(rootPath, 'init')) === false) {
|
|
60
60
|
fs.mkdir(path.join(rootPath, 'init'), () => {
|
|
61
|
-
//console.log(`'init' directory created
|
|
61
|
+
//console.log(`'init' directory created.`);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (fs.existsSync(path.join(rootPath, 'snapshots')) === false) {
|
|
66
66
|
fs.mkdir(path.join(rootPath, 'snapshots'), () => {
|
|
67
|
-
//console.log(`'snapshots' directory created
|
|
67
|
+
//console.log(`'snapshots' directory created.`);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -179,6 +179,10 @@ try {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
writeStream.write(`\n\n# EMAIL_TRANSPORT="sendgrid"\n`);
|
|
183
|
+
writeStream.write(`# EMAIL_SENDGRID_API_KEY="your-sendgrid-key"\n`);
|
|
184
|
+
writeStream.write(`# EMAIL_FROM="sender@email"\n`);
|
|
185
|
+
|
|
182
186
|
writeStream.end();
|
|
183
187
|
|
|
184
188
|
console.log("\nYou can always edit the variables that we've just set in the .env file manually.\n\n");
|
|
@@ -10,19 +10,27 @@ import jq from 'node-jq';
|
|
|
10
10
|
dotenv.config();
|
|
11
11
|
|
|
12
12
|
function outputDone() {
|
|
13
|
+
dotenv.config();
|
|
13
14
|
if (process.env.DIRECTUS_DOMAIN === 'localhost') {
|
|
14
15
|
var appURL = 'http://localhost';
|
|
15
16
|
} else {
|
|
16
17
|
var appURL = process.env.DIRECTUS_DOMAIN;
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
const sandboxURL = `https://studio.apollographql.com/sandbox/explorer?endpoint=${process.env.API_ENDPOINT}`;
|
|
21
|
+
|
|
19
22
|
console.log(chalk.green("\nAll services should be ready. You can access them at the following URLs:\n"));
|
|
20
23
|
console.log(`Directus CMS: ${chalk.cyan(process.env.PUBLIC_URL)}`);
|
|
21
24
|
console.log(`Adminer: ${chalk.cyan(appURL + ":8080")}`);
|
|
22
|
-
console.log(`
|
|
25
|
+
console.log(`GraphQL Playground: ${chalk.cyan(sandboxURL)}`);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Safari does not support network requests from Studio on HTTPS to your local HTTP endpoint, so we cannot reach your endpoint.
|
|
29
|
+
* Solution: use Chrome or Firefox to access the Studio.
|
|
30
|
+
*/
|
|
23
31
|
|
|
24
|
-
console.log(`\n${chalk.redBright("Note: learn how to avoid CORS errors in the
|
|
25
|
-
console.log(`https://github.com/rollmug/directus-mysql-template#cors-problems-on-localhost`)
|
|
32
|
+
// console.log(`\n${chalk.redBright("Note: learn how to avoid CORS errors in the GraphQL Playground when running on localhost:")}`);
|
|
33
|
+
// console.log(`https://github.com/rollmug/directus-mysql-template#cors-problems-on-localhost`)
|
|
26
34
|
|
|
27
35
|
console.log(`\n${chalk.green("When you're finished, you can stop all running containers with:")}\n`);
|
|
28
36
|
console.log(`npm run stop\n`);
|
|
@@ -31,7 +39,8 @@ function outputDone() {
|
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
export default function launchServices() {
|
|
34
|
-
|
|
42
|
+
dotenv.config();
|
|
43
|
+
const launch = spawn('docker', ['compose', 'up', '-d', 'mysql']);
|
|
35
44
|
|
|
36
45
|
const opts = {
|
|
37
46
|
resources: [
|
|
@@ -68,7 +77,7 @@ export default function launchServices() {
|
|
|
68
77
|
logUpdate("Building and launching containers:\n");
|
|
69
78
|
logUpdate.done();
|
|
70
79
|
|
|
71
|
-
const launch2 = spawn('docker
|
|
80
|
+
const launch2 = spawn('docker', ['compose', 'up', '-d']);
|
|
72
81
|
|
|
73
82
|
launch2.stderr.on('data', (data) => {
|
|
74
83
|
logUpdate(`${data}`);
|
|
@@ -78,9 +87,11 @@ export default function launchServices() {
|
|
|
78
87
|
logUpdate('Done.');
|
|
79
88
|
logUpdate.done();
|
|
80
89
|
|
|
90
|
+
const publicURL = process.env.PUBLIC_URL;
|
|
91
|
+
|
|
81
92
|
const pingOpts = {
|
|
82
93
|
resources: [
|
|
83
|
-
`${
|
|
94
|
+
`${publicURL}`
|
|
84
95
|
],
|
|
85
96
|
delay: 1000,
|
|
86
97
|
interval: 300,
|
|
@@ -88,7 +99,12 @@ export default function launchServices() {
|
|
|
88
99
|
tcpTimeout: 40000
|
|
89
100
|
}
|
|
90
101
|
|
|
91
|
-
|
|
102
|
+
if(!publicURL) {
|
|
103
|
+
logUpdate(`${chalk.redBright("Error: PUBLIC_URL is not set in the .env file.")}`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
logUpdate(`Pinging directus at: ${publicURL}`);
|
|
92
108
|
const loader2 = ora('Waiting for Directus to be ready').start();
|
|
93
109
|
|
|
94
110
|
waitOn(pingOpts).then(() => {
|
|
@@ -111,10 +127,13 @@ export default function launchServices() {
|
|
|
111
127
|
} else {
|
|
112
128
|
var appURL = process.env.DIRECTUS_DOMAIN;
|
|
113
129
|
}
|
|
130
|
+
|
|
131
|
+
const sandboxURL = `https://studio.apollographql.com/sandbox/explorer?endpoint=${process.env.API_ENDPOINT}`;
|
|
114
132
|
|
|
115
133
|
open(process.env.PUBLIC_URL);
|
|
116
134
|
open(`${appURL}:8080`);
|
|
117
|
-
open(`${appURL}:4000/graphql`);
|
|
135
|
+
// open(`${appURL}:4000/graphql`);
|
|
136
|
+
open(sandboxURL);
|
|
118
137
|
} else {
|
|
119
138
|
process.exit(1);
|
|
120
139
|
}
|
|
@@ -125,7 +144,7 @@ export default function launchServices() {
|
|
|
125
144
|
//It may be that it's running, so let's be sure.
|
|
126
145
|
logUpdate('Directus taking a long time to respond...');
|
|
127
146
|
|
|
128
|
-
const check = spawn('docker
|
|
147
|
+
const check = spawn('docker', ['compose', 'ps', '-a', '--format', 'json']);
|
|
129
148
|
|
|
130
149
|
check.stdout.on('data', (data) => {
|
|
131
150
|
const q = 'map(select(.Name == "directus")) | .[0] | {Name: .Name, Service: .Service, State: .State}';
|
|
@@ -146,12 +165,12 @@ export default function launchServices() {
|
|
|
146
165
|
if (code !== 0) {
|
|
147
166
|
var line1 = `${chalk.redBright("Directus taking too long to respond. You may need to manually start it.")}`;
|
|
148
167
|
var line2 = `Just run ${chalk.greenBright("npm run launch")} and you should be good to go.`;
|
|
149
|
-
var line3 = `You can also check if it is running with ${chalk.greenBright("docker
|
|
168
|
+
var line3 = `You can also check if it is running with ${chalk.greenBright("docker compose ps")}`;
|
|
150
169
|
logUpdate(`${line1} \n${line2} \n${line3}`);
|
|
151
170
|
} else {
|
|
152
171
|
var line1 = `${chalk.yellowBright("Directus appears to be running, but took a while to respond.")}`;
|
|
153
172
|
var line2 = `Just run ${chalk.greenBright("npm run launch")} to verify, and you should be good to go.`;
|
|
154
|
-
var line3 = `You can also check if it is running with ${chalk.greenBright("docker
|
|
173
|
+
var line3 = `You can also check if it is running with ${chalk.greenBright("docker compose ps")}`;
|
|
155
174
|
logUpdate(`${line1} \n${line2} \n${line3}`);
|
|
156
175
|
}
|
|
157
176
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "directus-mysql-docker",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "A helper app to configure Directus on Docker with MySQL, Adminer, and GraphQL",
|
|
3
|
+
"version": "1.2.7",
|
|
4
|
+
"description": "A helper app to configure Directus on Docker with MySQL, Adminer, and Apollo GraphQL Sandbox",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "node ./lib/index.js",
|
|
9
9
|
"launch": "node ./lib/index.js",
|
|
10
|
-
"stop": "docker
|
|
11
|
-
"snapshot": "docker
|
|
12
|
-
"snapshot-apply": "docker
|
|
13
|
-
"snapshot-test": "docker
|
|
10
|
+
"stop": "docker compose down",
|
|
11
|
+
"snapshot": "docker compose exec directus npx directus schema snapshot /directus/snapshots/\"$(date \"+%F\")\"-snapshot-\"$(date \"+%s\")\".yaml",
|
|
12
|
+
"snapshot-apply": "docker compose exec directus npx directus schema apply /directus/snapshots/$npm_config_snapshot",
|
|
13
|
+
"snapshot-test": "docker compose exec directus npx directus schema apply --dry-run /directus/snapshots/$npm_config_snapshot"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
16
|
"create-directus-docker": "./lib/index.js",
|