This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusdocker_wordpress.js
96 lines (78 loc) · 2.79 KB
/
usdocker_wordpress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'use strict';
const usdocker = require('@usdocker/usdocker');
const fs = require('fs');
const fsutil = usdocker.fsutil();
const path = require('path');
const SCRIPTNAME = 'wordpress';
let config = usdocker.config(SCRIPTNAME);
let configGlobal = usdocker.configGlobal();
const CONTAINERNAME = SCRIPTNAME + configGlobal.get('container-suffix');
function getContainerDef() {
let docker = usdocker.dockerRunWrapper(configGlobal);
if (config.get('enableDebug') === 'true') {
docker.env('WORDPRESS_DEBUG', 'true');
}
if (config.get('dbTablePrefix') !== '') {
docker.env('WORDPRESS_TABLE_PREFIX', config.get('dbTablePrefix'));
}
return docker
.containerName(CONTAINERNAME)
.port(config.get('port'), 80)
.volume(path.join(config.get('folder'), 'wp-content'), '/var/www/html/wp-content')
.volume(path.join(config.getUserDir('conf'), 'uploads.ini'), '/usr/local/etc/php/conf.d/uploads.ini')
.env('WORDPRESS_DB_HOST', config.get('db'))
.env('WORDPRESS_DB_USER', config.get('dbUser'))
.env('WORDPRESS_DB_PASSWORD', config.get('dbPassword'))
.env('WORDPRESS_DB_NAME', config.get('dbName'))
.isDetached(true)
.isRemove(true)
.imageName(config.get('image'))
;
}
module.exports = {
setup: function(callback)
{
config.setEmpty('image', 'wordpress:4.8-php7.1');
config.setEmpty('folder', config.getDataDir());
config.setEmpty('port', 8080);
config.setEmpty('db', 'mysql' + configGlobal.get('container-suffix'));
config.setEmpty('dbUser', 'root');
config.setEmpty('dbPassword', 'password');
config.setEmpty('dbName', 'wordpress');
config.setEmpty('dbTablePrefix', '');
config.setEmpty('enableDebug', 'false');
config.copyToUserDir(path.join(__dirname, 'wordpress', 'conf'));
let folderList = [
config.get('folder'),
];
for (let i=0; i<folderList.length; i++) {
if (!fs.existsSync(folderList[i])) {
fsutil.makeDirectory(folderList[i]);
}
}
callback(null, 'setup loaded for ' + SCRIPTNAME);
},
debugcli(callback) {
let result = usdocker.outputRaw('cli', getContainerDef());
callback(result);
},
debugapi(callback) {
let result = usdocker.outputRaw('api', getContainerDef());
callback(result);
},
up: function(callback)
{
usdocker.up(CONTAINERNAME, getContainerDef(), callback);
},
status: function(callback) {
usdocker.status(CONTAINERNAME, callback);
},
down: function(callback)
{
usdocker.down(CONTAINERNAME, callback);
},
restart: function(callback)
{
usdocker.restart(CONTAINERNAME, getContainerDef(), callback);
}
};