create-directus-docker 1.7.2 → 1.7.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/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.7.2",
4
+ "version": "1.7.4",
5
5
  "type": "module",
6
6
  "author": {
7
7
  "name": "Dave Kobrenski",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/rollmug/directus-mysql-template"
22
+ "url": "git+https://github.com/rollmug/directus-mysql-template.git"
23
23
  },
24
24
  "homepage": "https://github.com/rollmug/directus-mysql-template#readme",
25
25
  "scripts": {
@@ -30,6 +30,7 @@
30
30
  "copy:compose-nginx": "copy-file ../directus-mysql-template/docker-compose-nginx.yml ./templates/default/docker-compose-nginx.yml",
31
31
  "copy:readme": "copy-file ../directus-mysql-template/README.md ./templates/default/README.md",
32
32
  "copy:lib": "copyfiles --flat ../directus-mysql-template/lib/*.js ./templates/default/lib",
33
+ "copy:redis": "copyfiles --flat ../directus-mysql-template/redis/* ./templates/default/redis",
33
34
  "copy:conf": "copy-file ../directus-mysql-template/custom_proxy_settings.conf ./templates/default/custom_proxy_settings.conf"
34
35
  },
35
36
  "files": [
@@ -39,7 +39,7 @@ services:
39
39
 
40
40
  mysql:
41
41
  container_name: mysql
42
- image: mysql:9.1.0
42
+ image: mysql:9.5.0
43
43
  restart: always
44
44
  healthcheck:
45
45
  test: ['CMD', 'mysqladmin', 'ping', '--silent']
@@ -52,9 +52,8 @@ services:
52
52
  ports:
53
53
  - 3306:3306
54
54
  volumes:
55
- - ./mysql:/var/lib/mysql
55
+ - mysql-data:/var/lib/mysql
56
56
  - ./init:/docker-entrypoint-initdb.d
57
- # command: --mysql-native-password=ON
58
57
  environment:
59
58
  MYSQL_USER: ${MYSQL_USER}
60
59
  MYSQL_PASSWORD: ${MYSQL_PASS}
@@ -79,20 +78,28 @@ services:
79
78
 
80
79
  cache:
81
80
  container_name: cache
82
- image: redis:6.2.6
81
+ build:
82
+ context: ./redis
83
+ restart: always
84
+ privileged: true
85
+ environment:
86
+ REDIS_PASSWORD: ${REDIS_PASSWORD}
87
+ command: ["sh", "-c", "./init.sh"]
83
88
  healthcheck:
84
- test: ["CMD-SHELL", "[ $$(redis-cli ping) = 'PONG' ]"]
89
+ test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
85
90
  interval: 10s
86
91
  timeout: 5s
87
92
  retries: 5
88
93
  start_interval: 5s
89
94
  start_period: 30s
95
+ volumes:
96
+ - redis_data:/data:rw
90
97
  networks:
91
98
  - directus
92
99
 
93
100
  directus:
94
101
  container_name: directus
95
- image: directus/directus:11.3.5
102
+ image: directus/directus:11.13.0
96
103
  restart: always
97
104
  ports:
98
105
  - ${DIRECTUS_PORT}:8055
@@ -114,9 +121,12 @@ services:
114
121
  DB_CLIENT: 'mysql'
115
122
  DB_HOST: 'mysql'
116
123
  DB_USER: ${MYSQL_USER}
124
+ PROJECT_OWNER: ${PROJECT_OWNER}
125
+ ACCEPT_TERMS: 'true'
117
126
  DB_PASSWORD: ${MYSQL_PASS}
118
127
  DB_DATABASE: ${MYSQL_DB}
119
128
  DB_PORT: '3306'
129
+ REDIS_PASSWORD: ${REDIS_PASSWORD}
120
130
 
121
131
  VIRTUAL_HOST: ${VIRTUAL_HOST}
122
132
  VIRTUAL_PORT: ${DIRECTUS_PORT}
@@ -125,7 +135,7 @@ services:
125
135
 
126
136
  CACHE_ENABLED: 'true'
127
137
  CACHE_STORE: 'redis'
128
- REDIS: 'redis://cache:6379'
138
+ REDIS: 'redis://default:${REDIS_PASSWORD}@cache:6379'
129
139
  CACHE_AUTO_PURGE: 'true'
130
140
  CACHE_SYSTEM_TTL: '2m'
131
141
  CACHE_SCHEMA: 'false'
@@ -152,4 +162,6 @@ volumes:
152
162
  vhost:
153
163
  html:
154
164
  certs:
155
- acme:
165
+ acme:
166
+ redis_data:
167
+ mysql-data:
@@ -2,7 +2,7 @@ services:
2
2
 
3
3
  mysql:
4
4
  container_name: mysql
5
- image: mysql:9.1.0
5
+ image: mysql:9.5.0
6
6
  restart: always
7
7
  healthcheck:
8
8
  test: ['CMD', 'mysqladmin', 'ping', '--silent']
@@ -17,7 +17,6 @@ services:
17
17
  volumes:
18
18
  - mysql-data:/var/lib/mysql
19
19
  - ./init:/docker-entrypoint-initdb.d
20
- # command: --mysql-native-password=ON
21
20
  environment:
22
21
  MYSQL_USER: ${MYSQL_USER}
23
22
  MYSQL_PASSWORD: ${MYSQL_PASS}
@@ -42,20 +41,28 @@ services:
42
41
 
43
42
  cache:
44
43
  container_name: cache
45
- image: redis:6.2.19
44
+ build:
45
+ context: ./redis
46
+ restart: always
47
+ privileged: true
48
+ environment:
49
+ REDIS_PASSWORD: ${REDIS_PASSWORD}
50
+ command: ["sh", "-c", "REDIS_PASSWORD=${REDIS_PASSWORD} ./init.sh"]
46
51
  healthcheck:
47
- test: ["CMD-SHELL", "[ $$(redis-cli ping) = 'PONG' ]"]
52
+ test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
48
53
  interval: 10s
49
54
  timeout: 5s
50
55
  retries: 5
51
56
  start_interval: 5s
52
57
  start_period: 30s
58
+ volumes:
59
+ - redis_data:/data:rw
53
60
  networks:
54
61
  - directus
55
62
 
56
63
  directus:
57
64
  container_name: directus
58
- image: directus/directus:11.12.0
65
+ image: directus/directus:11.13.0
59
66
  restart: always
60
67
  ports:
61
68
  - ${DIRECTUS_PORT}:8055
@@ -75,13 +82,16 @@ services:
75
82
  DB_CLIENT: 'mysql'
76
83
  DB_HOST: 'mysql'
77
84
  DB_USER: ${MYSQL_USER}
85
+ PROJECT_OWNER: ${PROJECT_OWNER}
86
+ ACCEPT_TERMS: 'true'
78
87
  DB_PASSWORD: ${MYSQL_PASS}
79
88
  DB_DATABASE: ${MYSQL_DB}
80
89
  DB_PORT: '3306'
90
+ REDIS_PASSWORD: ${REDIS_PASSWORD}
81
91
 
82
92
  CACHE_ENABLED: 'true'
83
93
  CACHE_STORE: 'redis'
84
- REDIS: 'redis://cache:6379'
94
+ REDIS: 'redis://default:${REDIS_PASSWORD}@cache:6379'
85
95
  CACHE_AUTO_PURGE: 'true'
86
96
  CACHE_SYSTEM_TTL: '2m'
87
97
  CACHE_SCHEMA: 'false'
@@ -102,6 +112,7 @@ services:
102
112
 
103
113
  volumes:
104
114
  mysql-data:
115
+ redis_data:
105
116
  networks:
106
117
  directus:
107
118
  driver: bridge
@@ -1,5 +1,9 @@
1
1
  # This is a sample .env file with all possible options
2
2
 
3
+ # Directus Instance Owner
4
+ # this is to comply with the Directus BSL License 1.1
5
+ PROJECT_OWNER="you@email"
6
+
3
7
  # Email and password to login to Directus:
4
8
  ADMIN_EMAIL="you@email"
5
9
  ADMIN_PASSWORD="s0mEpa55w0rd"
@@ -14,6 +18,9 @@ MYSQL_DB="directus"
14
18
  # Set a root password for MySQL to something secure:
15
19
  MYSQL_ROOT_PASS="s0mEpa55w0rd"
16
20
 
21
+ # Set a password for redis
22
+ REDIS_PASSWORD="s0mEpa55w0rd"
23
+
17
24
  # Set the domain for directus to use:
18
25
  # eg, https://mydomain.com
19
26
  # in local dev environments, just leave it set to localhost:port
@@ -43,11 +43,11 @@ try {
43
43
  let git = await gitData();
44
44
  let mode = 0o777;
45
45
 
46
- if (fs.existsSync(path.join(rootPath, 'mysql')) === false) {
47
- fs.mkdir(path.join(rootPath, 'mysql'), () => {
48
- //console.log(`'mysql' directory created.`);
49
- });
50
- }
46
+ // if (fs.existsSync(path.join(rootPath, 'mysql')) === false) {
47
+ // fs.mkdir(path.join(rootPath, 'mysql'), () => {
48
+ // //console.log(`'mysql' directory created.`);
49
+ // });
50
+ // }
51
51
 
52
52
  if (fs.existsSync(path.join(rootPath, 'directus')) === false) {
53
53
  fs.mkdir(path.join(rootPath, 'directus'), { mode }, () => {
@@ -97,6 +97,21 @@ try {
97
97
  }
98
98
  }
99
99
  },
100
+ {
101
+ name: 'PROJECT_OWNER',
102
+ message: "Directus Instance Owner (email):",
103
+ default: git.email,
104
+ validate: (email) => {
105
+ let valid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)
106
+
107
+ if (valid) {
108
+ return true;
109
+ } else {
110
+ console.log(chalk.red("\nPlease enter a valid email."))
111
+ return false;
112
+ }
113
+ }
114
+ },
100
115
  {
101
116
  name: 'MYSQL_USER',
102
117
  message: "Specify a user name for your MySQL database:",
@@ -117,6 +132,11 @@ try {
117
132
  message: "Root password:",
118
133
  default: generator.generate({ length: 14, numbers: true, symbols: false })
119
134
  },
135
+ {
136
+ name: 'REDIS_PASSWORD',
137
+ message: "Redis cache password:",
138
+ default: generator.generate({ length: 14, numbers: true, symbols: false })
139
+ },
120
140
  {
121
141
  name: 'DIRECTUS_DOMAIN',
122
142
  message: "Web address to run on. For example, 'https://mydomain.com' Leave as localhost if running in dev environment.",
@@ -132,7 +152,10 @@ try {
132
152
  console.log(answers);
133
153
 
134
154
  var writeStream = fs.createWriteStream(envPath);
135
- writeStream.write("# Environment variables\n\n# Email and password to login to Directus:\n");
155
+ writeStream.write("# Environment variables\n\n# Directus Instance Owner\n# This is to comply with the Directus BSL License 1.1\n");
156
+ writeStream.write(`PROJECT_OWNER="${answers.PROJECT_OWNER}"`);
157
+ writeStream.write("\n\n");
158
+ writeStream.write("# Email and password to login to Directus:\n");
136
159
  writeStream.write(`ADMIN_EMAIL="${answers.ADMIN_EMAIL}"`);
137
160
  writeStream.write("\n");
138
161
  writeStream.write(`ADMIN_PASSWORD="${answers.ADMIN_PASSWORD}"`);
@@ -156,6 +179,9 @@ try {
156
179
  writeStream.write(`MYSQL_ROOT_PASS="${answers.MYSQL_ROOT_PASS}"`);
157
180
  writeStream.write("\n\n");
158
181
 
182
+ writeStream.write("# Set a password for redis. Make sure this matches the password in the redis/init.sh file\n");
183
+ writeStream.write(`REDIS_PASSWORD="${answers.REDIS_PASSWORD}"\n\n`);
184
+
159
185
  writeStream.write("# Set the domain for directus to use:\n");
160
186
  writeStream.write("# eg, https://mydomain.com\n");
161
187
  writeStream.write("# in local dev environments, just leave it set to localhost:port\n");
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directus-mysql-docker",
3
- "version": "1.3.6",
3
+ "version": "1.4.0",
4
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",
@@ -0,0 +1,5 @@
1
+ FROM redis:8.2.1-alpine
2
+ WORKDIR /redis
3
+ COPY redis.conf /usr/local/etc/redis/redis.conf
4
+ COPY init.sh ./
5
+ RUN chmod +x init.sh
@@ -0,0 +1,30 @@
1
+ # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel.
2
+ # This will create latency and memory usage issues with Redis.
3
+ # To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root,
4
+ # and add it to your /etc/rc.local in order to retain the setting after a reboot.
5
+ # Redis must be restarted after THP is disabled.
6
+
7
+ echo never > /sys/kernel/mm/transparent_hugepage/enabled
8
+ echo never > /sys/kernel/mm/transparent_hugepage/defrag
9
+
10
+ # WARNING: The TCP backlog setting of 511 cannot be enforced
11
+ # because /proc/sys/net/core/somaxconn is set to the lower value of 128.
12
+
13
+ sysctl -w net.core.somaxconn=512
14
+
15
+ # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.
16
+ # To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot
17
+ # or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
18
+ # The overcommit_memory has 3 options.
19
+ # 0, the system kernel check if there is enough memory to be allocated to the process or not,
20
+ # if not enough, it will return errors to the process.
21
+ # 1, the system kernel is allowed to allocate the whole memory to the process
22
+ # no matter what the status of memory is.
23
+ # 2, the system kernel is allowed to allocate a memory whose size could be bigger than
24
+ # the sum of the size of physical memory and the size of exchange workspace to the process.
25
+
26
+ sysctl vm.overcommit_memory=1
27
+
28
+ # start redis server
29
+
30
+ redis-server /usr/local/etc/redis/redis.conf --loglevel warning --bind 0.0.0.0 --requirepass $REDIS_PASSWORD