Skip to content

Commit

Permalink
ci: Add memcached to sandbox (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
kesara authored Aug 15, 2023
1 parent 8e1c588 commit 0dd35d2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
31 changes: 29 additions & 2 deletions dev/deploy-to-container/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ async function main () {
dock.modem.followProgress(dbImageBuildStream, (err, res) => err ? reject(err) : resolve(res))
})
console.info('Building latest DB docker image successfully.')


// Pull latest memcached image
console.info('Pulling latest memcached image...')
const mcImagePullStream = await dock.pull(`memcached:latest`)
await new Promise((resolve, reject) => {
dock.modem.followProgress(mcImagePullStream, (err, res) => err ? reject(err) : resolve(res))
})
console.info('Pulled latest memcached image.')

// Pull latest Wagtail_website Base image
console.info('Pulling latest Wagtail_website branch docker image...')
const appImagePullStream = await dock.pull(`ghcr.io/ietf-tools/wagtail_website:${argv.appversion}`)
Expand All @@ -72,7 +80,8 @@ async function main () {
for (const container of containers) {
if (
container.Names.includes(`/ws-db-${branch}`) ||
container.Names.includes(`/ws-app-${branch}`)
container.Names.includes(`/ws-app-${branch}`) ||
container.Names.includes(`/ws-mc-${branch}`)
) {
console.info(`Terminating old container ${container.Id}...`)
const oldContainer = dock.getContainer(container.Id)
Expand Down Expand Up @@ -117,6 +126,22 @@ async function main () {
await dbContainer.start()
console.info('Created and started DB docker container successfully.')

// Create memcached container
console.info(`Creating memcached docker container... [ws-mc-${branch}]`)
const mcContainer = await dock.createContainer({
Image: 'memcached:latest',
name: `ws-mc-${branch}`,
Hostname: `ws-mc-${branch}`,
HostConfig: {
NetworkMode: 'shared',
RestartPolicy: {
Name: 'unless-stopped'
}
}
})
await mcContainer.start()
console.info('Created and started memcached docker container successfully.')

// Create App container
console.info(`Creating app docker container... [ws-app-${branch}]`)
const appContainer = await dock.createContainer({
Expand All @@ -133,6 +158,8 @@ async function main () {
`PGUSER=postgres`,
`PGPASSWORD=password`,
`SECRET_KEY=${nanoid(36)}`,
`CACHE_DEFAULT=ws-mc-${branch}:11211`,
`CACHE_SESSIONS=ws-mc-${branch}:11211`,
`ALLOWED_HOSTS=${hostname}`,
`PRIMARY_HOST=${hostname}`
],
Expand Down
8 changes: 8 additions & 0 deletions ietf/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
}
}

# Caches

if 'CACHE_DEFAULT' in env:
CACHES['default']['LOCATION'] = env.get('CACHE_DEFAULT')

if 'CACHE_SESSIONS' in env:
CACHES['sessions']['LOCATION'] = env.get('CACHE_SESSIONS')


# Logging

Expand Down

0 comments on commit 0dd35d2

Please sign in to comment.