Skip to content

Commit

Permalink
fix: move to docker compose v2
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop docker compose v1 compatibility, as that's no longer maintained.
See: https://docs.docker.com/compose/migrate/
  • Loading branch information
ismay committed Aug 14, 2024
1 parent 7646876 commit 2eb3f78
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/commands/d2-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Which will output something like this:

```sh
Commands:
d2 cluster compose <name> Run arbitrary docker-compose commands
d2 cluster compose <name> Run arbitrary docker compose commands
against a DHIS2 cluster.
NOTE: pass -- after <name> [aliases: c]
d2 cluster db Manage the database in a DHIS2 Docker
Expand Down
10 changes: 5 additions & 5 deletions packages/cluster/src/commands/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const run = async function (argv) {
const cfg = await resolveConfiguration(argv)

const args = _.slice(_.findIndex(x => x === 'compose') + 1)
reporter.debug('Passing arguments to docker-compose', args)
reporter.debug('Passing arguments to docker compose', args)

const cacheLocation = await initDockerComposeCache({
composeProjectName: name,
Expand All @@ -27,9 +27,9 @@ const run = async function (argv) {
process.exit(1)
}
const res = await tryCatchAsync(
'exec(docker-compose)',
'exec(docker compose)',
spawn(
'docker-compose',
'docker compose',
[
'-p',
makeComposeProject(name),
Expand All @@ -47,14 +47,14 @@ const run = async function (argv) {
)
)
if (res.err) {
reporter.error('Failed to run docker-compose command')
reporter.error('Failed to run docker compose command')
process.exit(1)
}
}

module.exports = {
command: 'compose <name>',
desc: 'Run arbitrary docker-compose commands against a DHIS2 cluster.\nNOTE: pass -- after <name>',
desc: 'Run arbitrary docker compose commands against a DHIS2 cluster.\nNOTE: pass -- after <name>',
aliases: 'c',
handler: run,
}
4 changes: 2 additions & 2 deletions packages/cluster/src/commands/down.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const run = async function (argv) {
reporter.info(`Winding down cluster ${chalk.cyan(name)}`)
try {
await exec({
cmd: 'docker-compose',
cmd: 'docker compose',
args: [
'-p',
makeComposeProject(name),
Expand All @@ -46,7 +46,7 @@ const run = async function (argv) {
})
}
} catch (e) {
reporter.error('Failed to execute docker-compose', e)
reporter.error('Failed to execute docker compose', e)
process.exit(1)
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cluster/src/commands/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const run = async function (argv) {
)

const res = await tryCatchAsync(
'exec(docker-compose)',
'exec(docker compose)',
exec({
cmd: 'docker-compose',
cmd: 'docker compose',
args: [
'-p',
makeComposeProject(name),
Expand Down
4 changes: 2 additions & 2 deletions packages/cluster/src/commands/restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const run = async function (argv) {
}
reporter.info(`Spinning up cluster version ${chalk.cyan(name)}`)
const res = await tryCatchAsync(
'exec(docker-compose)',
'exec(docker compose)',
exec({
cmd: 'docker-compose',
cmd: 'docker compose',
args: [
'-p',
makeComposeProject(name),
Expand Down
10 changes: 5 additions & 5 deletions packages/cluster/src/commands/up.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ const run = async function (argv) {
if (update) {
reporter.info('Pulling latest Docker images...')
const res = await tryCatchAsync(
'exec(docker-compose)::pull',
'exec(docker compose)::pull',
exec({
env: makeEnvironment(cfg),
cmd: 'docker-compose',
cmd: 'docker compose',
args: [
'-p',
makeComposeProject(name),
Expand Down Expand Up @@ -70,10 +70,10 @@ const run = async function (argv) {
reporter.info(`Spinning up cluster ${chalk.cyan(name)}`)

const res = await tryCatchAsync(
'exec(docker-compose)',
'exec(docker compose)',
exec({
env: makeEnvironment(cfg),
cmd: 'docker-compose',
cmd: 'docker compose',
args: [
'-p',
makeComposeProject(name),
Expand All @@ -86,7 +86,7 @@ const run = async function (argv) {
})
)
if (res.err) {
reporter.error('Failed to spin up cluster docker-compose cluster')
reporter.error('Failed to spin up cluster docker compose cluster')
process.exit(1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ module.exports.makeEnvironment = cfg => {
return env
}

// This has to match the normalization done by docker-compose to reliably get container statuses
// This has to match the normalization done by docker compose to reliably get container statuses
// from https://github.com/docker/compose/blob/c8279bc4db56f49cf2e2b80c8734ced1c418b856/compose/cli/command.py#L154
const normalizeName = name => name.replace(/[^-_a-z0-9]/g, '')

Expand Down
2 changes: 1 addition & 1 deletion packages/cluster/src/helpers/db/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = async ({ cacheLocation, name, path: dbPath, fat }) => {
args: [destinationFile, fat ? 'full' : ''],
pipe: false,
env: {
DOCKER_COMPOSE: `docker-compose -p ${composeProject}`,
DOCKER_COMPOSE: `docker compose -p ${composeProject}`,
},
})
}
2 changes: 1 addition & 1 deletion packages/cluster/src/helpers/db/restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const restoreFromFile = async ({ cacheLocation, dbFile, name }) => {
args: [dbFile],
pipe: false,
env: {
DOCKER_COMPOSE: `docker-compose -p ${makeComposeProject(name)}`,
DOCKER_COMPOSE: `docker compose -p ${makeComposeProject(name)}`,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/commands/debug/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const run = async () => {
const info = await envInfo.run(
{
System: ['OS', 'CPU', 'Memory', 'Shell'],
Binaries: ['Node', 'Yarn', 'npm', 'docker-compose', 'docker'],
Binaries: ['Node', 'Yarn', 'npm', 'docker'],
Utilities: ['Git'],
Virtualization: ['Docker', 'Docker Compose'],
IDEs: ['VSCode', 'Sublime Text'],
Expand Down

0 comments on commit 2eb3f78

Please sign in to comment.