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 f2c21da
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 86 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr-core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
env:
TERM: xterm
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
Expand Down Expand Up @@ -41,9 +42,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 All @@ -60,6 +58,8 @@ jobs:
run: |
lando version
lando config
docker -v
docker-compose -v
# This block should eventually become use lando/actions-leia@v2
- name: Generate tests
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: 4 additions & 4 deletions examples/proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ curl http://object-format.lndo.site | grep X-Lando-Test-Ssl || echo $? | grep 1
curl -k https://object-format.lndo.site | grep X-Lando-Test-Ssl | grep on

# Should generate a default certs config file and put it in the right place
docker exec landoproxyhyperion5000gandalfedition_proxy_1 cat /proxy_config/default-certs.yaml | grep certFile | grep /certs/cert.crt
docker exec landoproxyhyperion5000gandalfedition_proxy_1 cat /proxy_config/default-certs.yaml | grep keyFile | grep /certs/cert.key
docker exec landoproxyhyperion5000gandalfedition-proxy-1 cat /proxy_config/default-certs.yaml | grep certFile | grep /certs/cert.crt
docker exec landoproxyhyperion5000gandalfedition-proxy-1 cat /proxy_config/default-certs.yaml | grep keyFile | grep /certs/cert.key

# Should generate proxy cert files and move them into the right location as needed
docker exec landoproxy_web3_1 cat /proxy_config/web3.landoproxy.yaml| grep certFile | grep "/lando/certs/web3.landoproxy.crt"
docker exec landoproxy_web3_1 cat /proxy_config/web3.landoproxy.yaml| grep keyFile | grep "/lando/certs/web3.landoproxy.key"
docker exec landoproxy-web3-1 cat /proxy_config/web3.landoproxy.yaml| grep certFile | grep "/lando/certs/web3.landoproxy.crt"
docker exec landoproxy-web3-1 cat /proxy_config/web3.landoproxy.yaml| grep keyFile | grep "/lando/certs/web3.landoproxy.key"
```

Destroy tests
Expand Down
4 changes: 2 additions & 2 deletions examples/scanner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Run the following commands to validate things are rolling as they should.

```bash
# Should set 80,443 in io.lando.http-ports label by default
docker inspect landoscanner_scanme_1 | grep io.lando.http-ports | grep "80,443"
docker inspect landoscanner-scanme-1 | grep io.lando.http-ports | grep "80,443"

# Should add an extra port to io.lando.http-ports if specified
docker inspect landoscanner_moreports_1 | grep io.lando.http-ports | grep "80,443,8888"
docker inspect landoscanner-moreports-1 | grep io.lando.http-ports | grep "80,443,8888"
```

Destroy tests
Expand Down
4 changes: 2 additions & 2 deletions examples/services/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ lando rebuild -y
# Should rerun build steps even if containers are manually removed and stuff
lando destroy -y
lando start -y
docker rm -f landoservices_nginx_1
docker rm -f landoservices_appserver_1
docker rm -f landoservices-nginx-1
docker rm -f landoservices-appserver-1
lando start -y
lando ssh -s appserver -c "vim --version"
lando ssh -s appserver -c "cat /var/www/build.txt"
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: 4 additions & 4 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ module.exports = class Engine {
* @example
*
* // Check to see if our app's web service is running
* return lando.engine.isRunning('myapp_web_1').then(isRunning) {
* lando.log.info('Container %s is running: %s', 'myapp_web_1', isRunning);
* return lando.engine.isRunning('myapp-web-1').then(isRunning) {
* lando.log.info('Container %s is running: %s', 'myapp-web-1', isRunning);
* });
*/
isRunning(data) {
Expand Down Expand Up @@ -292,11 +292,11 @@ module.exports = class Engine {
* @example
*
* // Run composer install on the appserver container for an app called myapp
* return lando.engine.run({id: 'myapp_appserver_1', cmd: ['composer', 'install']});
* return lando.engine.run({id: 'myapp-appserver-1', cmd: ['composer', 'install']});
*
* // Drop into an interactive bash shell on the database continer for an app called myapp
* return lando.engine.run({
* id: 'myapp_database_1',
* id: 'myapp-database-1',
* cmd: ['bash'],
* opts: {
* mode: 'attach'
Expand Down
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
2 changes: 1 addition & 1 deletion plugins/lando-events/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports.events2Runz = (cmds, app, data = {}) => _.map(cmds, cmd => {
}
// Add the build command
return {
id: `${app.project}_${service}_1`,
id: `${app.project}-${service}-1`,
cmd: ['/bin/sh', '-c', _.isArray(command) ? command.join(' ') : command],
compose: app.compose,
project: app.project,
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
2 changes: 1 addition & 1 deletion plugins/lando-recipes/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exports.runDefaults = (lando, options) => {
const project = `${lando.config.product}init` + utils.dockerComposify(options.name);
// Return
return {
id: `${project}_init_1`,
id: `${project}-init-1`,
project,
user: 'www-data',
compose: initFiles,
Expand Down

0 comments on commit f2c21da

Please sign in to comment.