Skip to content

Commit d9ec2e5

Browse files
authored
Merge pull request #598 from nextcloud-libraries/feat/perf-boost
perf(docker): put data into RAM + enable APCU
2 parents e0efb07 + 8bbfe6c commit d9ec2e5

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/docker.ts

+25-1
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,25 @@ export async function startNextcloud(branch = 'master', mountApp: boolean|string
173173
const container = await docker.createContainer({
174174
Image: SERVER_IMAGE,
175175
name: getContainerName(),
176-
Env: [`BRANCH=${branch}`],
176+
Env: [`BRANCH=${branch}`, 'APCU=1'],
177177
HostConfig: {
178178
Binds: mounts.length > 0 ? mounts : undefined,
179179
PortBindings,
180+
// Mount data directory in RAM for faster IO
181+
Mounts: [{
182+
Target: '/var/www/html/data',
183+
Source: '',
184+
Type: 'tmpfs',
185+
ReadOnly: false,
186+
}],
180187
},
181188
})
182189
await container.start()
183190

191+
// Set proper permissions for the data folder
192+
await runExec(container, ['chown', '-R', 'www-data:www-data', '/var/www/html/data'], false, 'root')
193+
await runExec(container, ['chmod', '0770', '/var/www/html/data'], false, 'root')
194+
184195
// Get container's IP
185196
const ip = await getContainerIP(container)
186197
console.log(`├─ Nextcloud container's IP is ${ip} 🌏`)
@@ -217,6 +228,19 @@ export const configureNextcloud = async function(apps = ['viewer'], vendoredBran
217228
await runExec(container, ['php', 'occ', 'config:system:set', 'force_locale', '--value', 'en_US'], true)
218229
await runExec(container, ['php', 'occ', 'config:system:set', 'enforce_theme', '--value', 'light'], true)
219230

231+
// Checking apcu
232+
console.log('├─ Checking APCu configuration... 👀')
233+
const distributed = await runExec(container, ['php', 'occ', 'config:system:get', 'memcache.distributed'])
234+
const local = await runExec(container, ['php', 'occ', 'config:system:get', 'memcache.local'])
235+
const hashing = await runExec(container, ['php', 'occ', 'config:system:get', 'hashing_default_password'])
236+
if (!distributed.includes('Memcache\\APCu')
237+
|| !local.includes('Memcache\\APCu')
238+
|| !hashing.includes('true')) {
239+
console.log('└─ APCu is not properly configured 🛑')
240+
throw new Error('APCu is not properly configured')
241+
}
242+
console.log('│ └─ OK !')
243+
220244
// Build app list
221245
const json = await runExec(container, ['php', 'occ', 'app:list', '--output', 'json'], false)
222246
// fix dockerode bug returning invalid leading characters

0 commit comments

Comments
 (0)