Skip to content

Commit

Permalink
Merge pull request #598 from nextcloud-libraries/feat/perf-boost
Browse files Browse the repository at this point in the history
perf(docker): put data into RAM + enable APCU
  • Loading branch information
susnux committed Aug 26, 2024
2 parents e0efb07 + 8bbfe6c commit d9ec2e5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,25 @@ export async function startNextcloud(branch = 'master', mountApp: boolean|string
const container = await docker.createContainer({
Image: SERVER_IMAGE,
name: getContainerName(),
Env: [`BRANCH=${branch}`],
Env: [`BRANCH=${branch}`, 'APCU=1'],
HostConfig: {
Binds: mounts.length > 0 ? mounts : undefined,
PortBindings,
// Mount data directory in RAM for faster IO
Mounts: [{
Target: '/var/www/html/data',
Source: '',
Type: 'tmpfs',
ReadOnly: false,
}],
},
})
await container.start()

// Set proper permissions for the data folder
await runExec(container, ['chown', '-R', 'www-data:www-data', '/var/www/html/data'], false, 'root')
await runExec(container, ['chmod', '0770', '/var/www/html/data'], false, 'root')

// Get container's IP
const ip = await getContainerIP(container)
console.log(`├─ Nextcloud container's IP is ${ip} 🌏`)
Expand Down Expand Up @@ -217,6 +228,19 @@ export const configureNextcloud = async function(apps = ['viewer'], vendoredBran
await runExec(container, ['php', 'occ', 'config:system:set', 'force_locale', '--value', 'en_US'], true)
await runExec(container, ['php', 'occ', 'config:system:set', 'enforce_theme', '--value', 'light'], true)

// Checking apcu
console.log('├─ Checking APCu configuration... 👀')
const distributed = await runExec(container, ['php', 'occ', 'config:system:get', 'memcache.distributed'])
const local = await runExec(container, ['php', 'occ', 'config:system:get', 'memcache.local'])
const hashing = await runExec(container, ['php', 'occ', 'config:system:get', 'hashing_default_password'])
if (!distributed.includes('Memcache\\APCu')
|| !local.includes('Memcache\\APCu')
|| !hashing.includes('true')) {
console.log('└─ APCu is not properly configured 🛑')
throw new Error('APCu is not properly configured')
}
console.log('│ └─ OK !')

// Build app list
const json = await runExec(container, ['php', 'occ', 'app:list', '--output', 'json'], false)
// fix dockerode bug returning invalid leading characters
Expand Down

0 comments on commit d9ec2e5

Please sign in to comment.