Skip to content

Commit

Permalink
reafctor!: drop docker-compose-v1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed May 15, 2024
1 parent 1e61f3a commit 8dcc5c2
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 72 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/pr-core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ jobs:
- name: Install Yarn dependencies
run: yarn install --prefer-offline --frozen-lockfile

- name: Install docker-compose
run: sudo wget -q https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose

# - name: Install via hyperdrive if above is bad
- name: Disable usage and error reporting
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pr-db-tools-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
- name: Install Yarn dependencies
run: yarn install --prefer-offline --frozen-lockfile

- name: Install docker-compose
run: sudo wget -q https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose

# - name: Install via hyperdrive if above is bad
- name: Disable usage and error reporting
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pr-django-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
- name: Install Yarn dependencies
run: yarn install --prefer-offline --frozen-lockfile

- name: Install docker-compose
run: sudo wget -q https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose

# - name: Install via hyperdrive if above is bad
- name: Disable usage and error reporting
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pr-plugins-installed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ jobs:
- name: Install Yarn dependencies
run: yarn install --prefer-offline --frozen-lockfile

- name: Install docker-compose
run: sudo wget -q https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose

# - name: Install via hyperdrive if above is bad
- name: Disable usage and error reporting
run: |
Expand Down
10 changes: 5 additions & 5 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ mode: cli

dockerSupportedVersions:
compose:
min: "1.23.0"
max: "1.30.0"
min: "2.0.0"
max: "2.99.99"
link:
linux: https://docs.docker.com/compose/install/#install-compose-on-linux-systems
desktop:
min: "2.1.0.0"
max: "3.6.99"
min: "4.0.0"
max: "4.99.99"
link:
darwin: https://docs.docker.com/docker-for-mac/release-notes/
win32: https://docs.docker.com/docker-for-windows/release-notes/
engine:
min: "18.09.3"
min: "26.99.9"
max: "20.10.99"
link:
linux: https://docs.docker.com/engine/install/
Expand Down
42 changes: 21 additions & 21 deletions examples/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ Run the following commands to verify things work as expected

```bash
# Should merge in all Landofiles correctly
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-log-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web2-1

# Should merge in all Landofiles correctly even if we are down a directory
cd docker-compose
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-log-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web2-1
cd ..

# Should load environment files from all Landofiles
Expand Down Expand Up @@ -104,9 +104,9 @@ lando info --format json
lando info --path "[0]" | grep service | wc -l | grep 1

# Should list this apps containers
lando list | grep landobase_log_1
lando list | grep landobase_web_1
lando list | grep landobase_web2_1
lando list | grep landobase-log-1
lando list | grep landobase-web-1
lando list | grep landobase-web2-1

# Should output JSON in lando list without error
lando list --format json
Expand All @@ -118,8 +118,8 @@ lando list --path "landobase" | grep landobase
lando logs

# Should return only logs for the specified service
lando logs -s web2 | grep log_1 || echo $? | grep 1
lando logs --service web2 | grep log_1 || echo $? | grep 1
lando logs -s web2 | grep log-1 || echo $? | grep 1
lando logs --service web2 | grep log-1 || echo $? | grep 1

# Should run a command as the LANDO_WEBROOT_USER by default
lando ssh -s web2 -c "id | grep \\\$LANDO_WEBROOT_USER"
Expand All @@ -139,23 +139,23 @@ docker ps --filter label=io.lando.container=TRUE -q | wc -l | grep 0

# Should rebuild the services without errors
lando rebuild -y
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-log-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web2-1

# Should only rebuild the specified services
lando rebuild -y --service web2
lando rebuild -y -s web2
docker ps --latest | grep landobase_web2_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1
docker ps --latest | grep landobase-web2-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-log-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web2-1

# Should restart the services without errors
lando restart
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-log-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web-1
docker ps --filter label=com.docker.compose.project=landobase | grep landobase-web2-1

# Should have non-numeric keys in LANDO_INFO
lando php info.php
Expand Down
8 changes: 2 additions & 6 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const loadPlugins = (app, lando) => Promise.resolve(app.plugins.registry)
// Merge minotaur
.each(result => _.merge(app, result));

const defaultComposeSeparator = '_';

/**
* The class to instantiate a new App
*
Expand Down Expand Up @@ -520,13 +518,11 @@ module.exports = class App {
};

getServiceContainerId(service) {
const sep = this._lando && this._lando.config && this._lando.config.composeSeparator || defaultComposeSeparator;
return `${this.project}${sep}${service}${sep}1`;
return `${this.project}-${service}-1`;
};

getServiceFromContainerId(id) {
const sep = this._lando && this._lando.config && this._lando.config.composeSeparator || defaultComposeSeparator;
const regex = new RegExp(`${this.project}${sep}(.*)${sep}1`);
const regex = new RegExp(`${this.project}-(.*)-1`);
return id.replace(regex, '$1');
};
};
5 changes: 2 additions & 3 deletions lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ const engineRunner = (config, command) => (argv, lando) => {
const app = lando.cache.get(path.basename(config.composeCache));
app.config = config;
app.events = new AsyncEvents(lando.log);
const sep = lando.config.composeSeparator;
app.getServiceContainerId = service => `${app.project}${sep}${service}${sep}1`;
app.getServiceFromContainerId = id => id.replace(new RegExp(`${app.project}${sep}(.*)${sep}1`), '$1');
app.getServiceContainerId = service => `${app.project}-${service}-1`;
app.getServiceFromContainerId = id => id.replace(new RegExp(`${app.project}-(.*)-1`), '$1');
// Load only what we need so we don't pay the appinit penalty
const utils = require('./../plugins/lando-tooling/lib/utils');
const buildTask = require('./../plugins/lando-tooling/lib/build');
Expand Down
16 changes: 0 additions & 16 deletions lib/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ const Promise = require('./promise');
const Shell = require('./shell');
const shell = new Shell();

// Constants
const composeV1Separator = '_';
const composeV2Separator = '-';

/*
* Creates a new Daemon instance.
*/
Expand Down Expand Up @@ -103,16 +99,4 @@ module.exports = class LandoDaemon {
engine: _.trim(data[0]),
}));
};

getComposeSeparator() {
return this.compose ? new Promise(resolve => {
const semver = require('semver');
this.getVersions().then(versions => {
const isComposeV1 = semver.lt(versions.compose || '1.0.0', '2.0.0');

const composeSeparator = isComposeV1 ? composeV1Separator : composeV2Separator;
resolve(composeSeparator);
});
}) : Promise.resolve(composeV1Separator);
}
};
8 changes: 1 addition & 7 deletions lib/lando.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ const bootstrapEngine = lando => {
lando.utils = _.merge({}, require('./utils'), require('./config'));


const separatorPromise = new Promise(resolve => {
lando.engine.daemon.getComposeSeparator().then(sep => {
lando.config.composeSeparator = sep;
resolve();
});
});
// Auto move and make executable any scripts
const pluginPromise = lando.Promise.map(lando.config.plugins, plugin => {
if (fs.existsSync(plugin.scripts)) {
Expand All @@ -122,7 +116,7 @@ const bootstrapEngine = lando => {
}
});

return Promise.all([pluginPromise, separatorPromise]);
return Promise.all([pluginPromise]);
};

/*
Expand Down
3 changes: 1 addition & 2 deletions plugins/lando-proxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ module.exports = lando => {
});

lando.events.on('post-bootstrap-engine', () => {
const sep = lando.config.composeSeparator;
lando.config.proxyContainer = `${lando.config.proxyName}${sep}proxy${sep}1`;
lando.config.proxyContainer = `${lando.config.proxyName}-proxy-1`;
});

// Return config defaults to rebase
Expand Down

0 comments on commit 8dcc5c2

Please sign in to comment.