Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(docker): put data into RAM + enable APCU #598

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading