Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ce-dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
mkdir -p ~/.config/ce-dev
touch ~/.config/ce-dev/preferences-1.x.yml
echo 'docker_bin: docker' > ~/.config/ce-dev/preferences-1.x.yml
echo 'docker_compose_bin: docker-compose' >> ~/.config/ce-dev/preferences-1.x.yml
echo 'docker_compose_bin: docker compose' >> ~/.config/ce-dev/preferences-1.x.yml
echo 'mkcert_bin: mkcert' >> ~/.config/ce-dev/preferences-1.x.yml
- name: Build and push Docker images
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A local stack based on Docker Compose and Ansible. It aims to be easy to use but
- HTTPS support through [mkcert](https://github.com/FiloSottile/mkcert)
- Built-in Unison sync to avoid bind mount slowness on Mac OS
- Easily build and push ready made images from running containers for you project
- Only defines a few simple commands, and defers to docker-compose and Ansible beyond that
- Only defines a few simple commands, and defers to `docker compose` and Ansible beyond that

## [Documentation](https://codeenigma.github.io/ce-dev-docs/1.x/home/)
## [Install](https://codeenigma.github.io/ce-dev-docs/1.x/install/)
## [Install](https://codeenigma.github.io/ce-dev-docs/1.x/install/)
9 changes: 2 additions & 7 deletions RELEASE
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
1.1.23
Changed credentials_handling to manual, to generate ce-dev and root as user/password instead of a random string.
Using vendor/drush as drush instead of the phar file.
Included lhci_run as role in the deploy step, with one tests for the homepage.
Using full command paths to define pre/post_tasks
Renamed the settings and drush templates inside ansible/web/site/default
Removed the pre_tasks in provision.yml to uninstall nodejs 12.
1.2.0
Migrated to using docker compose v2 or higher.
16 changes: 8 additions & 8 deletions docs/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ _See code: [src/commands/browse.ts](https://github.com/codeenigma/ce-dev/blob/v1

## `ce-dev build`

Commit the existing containers as new docker images, and create a new docker-compose file referencing them.
Commit the existing containers as new docker images, and create a new docker compose file referencing them.

```
USAGE
$ ce-dev build

OPTIONS
-d, --destination=destination [default: ce-dev.compose.prebuilt.yml] Path to the output docker-compose file, relative
-d, --destination=destination [default: ce-dev.compose.prebuilt.yml] Path to the output docker compose file, relative
to the project ce-dev folder.

-h, --help show CLI help

-r, --registry=registry Docker registry to use. This overrides the one defined in the source compose template.

-t, --template=template [default: ce-dev.compose.yml] Path to a docker-compose template file, relative to the
-t, --template=template [default: ce-dev.compose.yml] Path to a docker compose template file, relative to the
project ce-dev folder. WARNING: this must match the original one the project was
constructed with.

Expand Down Expand Up @@ -151,7 +151,7 @@ _See code: [src/commands/deploy.ts](https://github.com/codeenigma/ce-dev/blob/v1

## `ce-dev destroy`

Destroy project's containers using docker-compose kill.
Destroy project's containers using docker compose kill.

```
USAGE
Expand Down Expand Up @@ -194,7 +194,7 @@ USAGE
OPTIONS
-h, --help show CLI help

-t, --template=template [default: ce-dev.compose.prebuilt.yml] path to a docker-compose template file, relative to
-t, --template=template [default: ce-dev.compose.prebuilt.yml] path to a docker compose template file, relative to
the project root

EXAMPLE
Expand Down Expand Up @@ -231,7 +231,7 @@ OPTIONS

-r, --registry=registry Docker registry to use. This overrides the one defined in the source compose template.

-t, --template=template [default: ce-dev.compose.prebuilt.yml] Path to a docker-compose template file, relative to
-t, --template=template [default: ce-dev.compose.prebuilt.yml] Path to a docker compose template file, relative to
the project root. WARNING: this must match the original one the project was constructed with.

-u, --username=username Username to use to login against the Docker registry.
Expand Down Expand Up @@ -259,7 +259,7 @@ OPTIONS

-r, --registry=registry Docker registry to use. This overrides the one defined in the source compose template.

-t, --template=template [default: ce-dev.compose.prebuilt.yml] Path to a docker-compose template file, relative to
-t, --template=template [default: ce-dev.compose.prebuilt.yml] Path to a docker compose template file, relative to
the project root. WARNING: this must match the original one the project was constructed with.

-u, --username=username Username to use to login against the Docker registry.
Expand Down Expand Up @@ -292,7 +292,7 @@ _See code: [src/commands/shell.ts](https://github.com/codeenigma/ce-dev/blob/v1.

## `ce-dev start`

Spin up containers using docker-compose and update /etc/hosts file.
Spin up containers using docker compose and update /etc/hosts file.

```
USAGE
Expand Down
4 changes: 2 additions & 2 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting started

Note: this tutorial always refers to `docker` and `docker-compose`, never to `sudo docker` and `sudo docker-compose`, for readability. Adapt the commands accordingly for your setup.
Note: this tutorial always refers to `docker` and `docker compose`, never to `sudo docker` and `sudo docker compose`, for readability. Adapt the commands accordingly for your setup.
We also use indifferently "host", "host machine", "laptop" or "workstation" to refer to the machine you're using ce-dev on; and "guest", "container" or "service" to refer to running containers. It will still work the same whether you actually use a laptop or not 😉

## Quickstart
Expand Down Expand Up @@ -38,7 +38,7 @@ Next step is to start our containers.
ce-dev start
```
What happened is:
- we called `docker-compose up`
- we called `docker compose up`
- ensured file permissions, ownership and uid/gid match between your user on the host and the 'ce-dev' user within the container
- started Unison file synchronisation
- updated the /etc/hosts file on your laptop
Expand Down
7 changes: 4 additions & 3 deletions docs/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ We also assume common utilities are present:

#### Docker

Follow the installation instructions for your distro from https://docs.docker.com/engine/install/. It is generally straightforward, except for users of [Fedora 31 and above](https://duckduckgo.com/?q=docker+fedora+32).
Follow the installation instructions for your distro from https://docs.docker.com/engine/install/. It is generally straightforward, except for users of [Fedora - more information here](https://fedoramagazine.org/docker-and-fedora-35/).

**_Shall I `sudo docker` or `docker`?_**
Most setup instructions you will find online instruct you to [add your user to the "docker" group](https://docs.docker.com/engine/install/linux-postinstall/) to be able to call docker as a standard user.
There is a [non-neglectable risk](https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface) with that approach, even though it is far more convenient than being prompted for your password each and every step.

By default, ce-dev will assume you went the "safe" way and use `sudo docker` or `sudo docker-compose`, but you can change that in your [global configuration](userconfig).
By default, ce-dev will assume you went the "safe" way and use `sudo docker` or `sudo docker compose`, but you can change that in your [global configuration](userconfig).

#### Docker Compose

Follow the installation instruction for your distro from https://docs.docker.com/compose/install/.
You will need Docker Compose v2 or higher. Linux users should install the `docker-compose-plugin` package from the Docker repository, if you do not have `docker compose` already: https://docs.docker.com/compose/install/linux/#install-using-the-repository

#### mkcert

Expand Down Expand Up @@ -92,6 +92,7 @@ Be sure to allow enough resources for it to run smoothly. There's no magic rule,
- Be generous on RAM, but do not allocate it all for Docker. If you do not set a limit and you run a resource hungry service, everything, including processes on the hosts (think Electron apps, Chrome and the like, and by cascade the Docker processes themselves) will end up swapping and being ultra slow. 8GB or 10GB out of 16GB should be reasonable values.
- Do not throttle CPU usage (ie, allocate them all). Or, go the other way round and allocate only one. This seems contradictory, but it looks like it behave diffently based on your hardware and/or OS version. In certain cases, containers seem to be unable to make use of more than one core anyway, so allocating more than one ends up being counter-productive as it will impede processes on the host.
- Make sure you have enough disk space allocated for the VM Disk image. This again will vary on usage, but with a dozen of projects that have a 10GB database each, you're already well over 100GB. On the other hand, **_you can always grow the virtual disk afterward, but you can NOT shrink it without destroying all containers and volumes_**, so you can start small and grow it as needed if you encounter some "no space left on device/disk full" errors.
- You might want to turn on the "Use Rosetta for x86/amd64 emulation on Apple Silicon" option in Docker under "Features in development". This speeds up the emulation significantly.

[![Docker Desktop setting pane](uploads/docker-mac-settings.png)](uploads/docker-mac-settings.png)

Expand Down
4 changes: 2 additions & 2 deletions docs/UserConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
You can access a few global settings using `ce-dev config`.

## Binaries
You can alter the commands called for 'docker', 'docker-compose' and 'mkcert'. This is mostly useful if you added your user to the 'docker' group on Linux and don't want to be prompted for your password. Or if you're doing funky stuff !
You can alter the commands called for 'docker', 'docker compose' and 'mkcert'. This is mostly useful if you added your user to the 'docker' group on Linux and don't want to be prompted for your password. Or if you're doing funky stuff !

## SSH Username and Key
Define the default username and private key to be used to be able to [SSH from containers to private resources](ssh), eg. cloning private repos or syncing environments back.
Define the default username and private key to be used to be able to [SSH from containers to private resources](ssh), eg. cloning private repos or syncing environments back.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ -n "$(which ce-dev)" ]; then
fi
fi
echo "Checking for dependencies..."
for BINARY in docker docker-compose mkcert; do
for BINARY in docker mkcert; do
if [ -z "$(which "$BINARY")" ]; then
echo "Could not find $BINARY"
echo "Ensure it is installed and in your \$PATH"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ce-dev",
"description": "Local Stack wrapper tool",
"version": "1.1.23",
"version": "1.2.0",
"author": " @pm98zz-c",
"bin": {
"ce-dev": "./bin/run"
Expand Down
2 changes: 1 addition & 1 deletion src/base-cmd-abstract-docker-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default abstract class DockerImagesCmd extends BaseCmd {
help: flags.help({char: 'h'}),
template: flags.string({
char: 't',
description: 'Path to a docker-compose template file, relative to the project root. WARNING: this must match the original one the project was constructed with.',
description: 'Path to a docker compose template file, relative to the project root. WARNING: this must match the original one the project was constructed with.',
default: 'ce-dev.compose.prebuilt.yml',
}),
username: flags.string({
Expand Down
8 changes: 4 additions & 4 deletions src/base-cmd-abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default abstract class BaseCmd extends Command {
* @member
* Docker-compose executable path.
*/
protected dockerComposeBin = 'docker-compose'
protected dockerComposeBin = 'docker compose'

/**
* @member
Expand Down Expand Up @@ -85,8 +85,8 @@ export default abstract class BaseCmd extends Command {
docker_bin: this.config.platform === 'linux' ? 'sudo docker' : 'docker',
docker_compose_bin:
this.config.platform === 'linux' ?
'sudo docker-compose' :
'docker-compose',
'sudo docker compose' :
'docker compose',
mkcert_bin: 'mkcert',
ssh_user: process.env.USER as string,
ssh_key: (process.env.HOME as string) + '/.ssh/id_rsa',
Expand Down Expand Up @@ -249,7 +249,7 @@ export default abstract class BaseCmd extends Command {
*
* @param file
* Path to a file to parse
* @returns Parsed docker-compose declaration.
* @returns Parsed docker compose declaration.
*/
protected loadComposeConfig(file: string): ComposeConfig {
// @todo Check config is valid.
Expand Down
6 changes: 3 additions & 3 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ux from 'cli-ux'

const fspath = require('path')
export default class BuildCmd extends BaseCmd {
static description = 'Commit the existing containers as new docker images, and create a new docker-compose file referencing them.'
static description = 'Commit the existing containers as new docker images, and create a new docker compose file referencing them.'

static examples = [
'$ ce-dev build --template example.compose.yml',
Expand All @@ -17,12 +17,12 @@ export default class BuildCmd extends BaseCmd {
help: flags.help({char: 'h'}),
template: flags.string({
char: 't',
description: 'Path to a docker-compose template file, relative to the project ce-dev folder. WARNING: this must match the original one the project was constructed with.',
description: 'Path to a docker compose template file, relative to the project ce-dev folder. WARNING: this must match the original one the project was constructed with.',
default: 'ce-dev.compose.yml',
}),
destination: flags.string({
char: 'd',
description: 'Path to the output docker-compose file, relative to the project ce-dev folder.',
description: 'Path to the output docker compose file, relative to the project ce-dev folder.',
default: 'ce-dev.compose.prebuilt.yml',
}),
registry: flags.string({
Expand Down
8 changes: 4 additions & 4 deletions src/commands/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {flags} from '@oclif/command'
import ux from 'cli-ux'

export default class DestroyCmd extends BaseCmd {
static description = 'Destroy project\'s containers using docker-compose kill.'
static description = 'Destroy project\'s containers using docker compose kill.'

static examples = [
'$ ce-dev destroy',
Expand Down Expand Up @@ -39,13 +39,13 @@ export default class DestroyCmd extends BaseCmd {
}

/**
* Wrapper around docker-compose.
* Wrapper around docker compose.
*/
private down(): void {
ux.action.start('Killing containers with docker-compose kill')
ux.action.start('Killing containers with docker compose kill')
execSync(this.dockerComposeBin + ' -p ' + this.activeProjectInfo.project_name + ' kill', {cwd: this.ceDevDir, stdio: 'inherit'})
ux.action.stop()
ux.action.start('Remove containers and anonymous volumes with docker-compose rm')
ux.action.start('Remove containers and anonymous volumes with docker compose rm')
execSync(this.dockerComposeBin + ' -p ' + this.activeProjectInfo.project_name + ' rm -v --force', {cwd: this.ceDevDir, stdio: 'inherit'})
ux.action.stop()
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class InitCmd extends BaseCmd {
help: flags.help({char: 'h'}),
template: flags.string({
char: 't',
description: 'path to a docker-compose template file, relative to the project root',
description: 'path to a docker compose template file, relative to the project root',
default: 'ce-dev.compose.prebuilt.yml',
}),
}
Expand Down Expand Up @@ -298,7 +298,7 @@ export default class InitCmd extends BaseCmd {
if (!service.volumes) {
service.volumes = []
}
service.volumes.push('/sys/fs/cgroup:/sys/fs/cgroup:ro')
service.volumes.push('/sys/fs/cgroup:/sys/fs/cgroup:rw')
service.volumes = [...new Set(service.volumes)]
if (!service.cap_add) {
service.cap_add = []
Expand Down
4 changes: 2 additions & 2 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fs = require('fs')
const readline = require('readline')

export default class StartCmd extends BaseCmd {
static description = 'Spin up containers using docker-compose and update /etc/hosts file.'
static description = 'Spin up containers using docker compose and update /etc/hosts file.'

static examples = [
'$ ce-dev start',
Expand Down Expand Up @@ -143,7 +143,7 @@ export default class StartCmd extends BaseCmd {
}

/**
* Wrapper around docker-compose.
* Wrapper around docker compose.
*/
private up(): void {
const running = this.getProjectRunningContainers()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class StopCmd extends BaseCmd {
*/
async run(): Promise<any> {
this.ensureActiveComposeFile()
ux.action.start('Stopping running containers with docker-compose stop')
ux.action.start('Stopping running containers with docker compose stop')
execSync(this.dockerComposeBin + ' -p ' + this.activeProjectInfo.project_name + ' stop', {cwd: this.ceDevDir})
this.stopControllerContainer()
ux.action.stop()
Expand Down
2 changes: 2 additions & 0 deletions src/compose-config-service-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import ComposeConfigServiceCeDev from './compose-config-service-ce-dev-interface
export default interface ComposeConfigService {
'container_name'?: string;
'image'?: string;
'platform'?: string;
'cgroup'?: 'host' | 'private';
'volumes'?: Array<string>;
'expose'?: Array<string>;
'ports'?: Array<string>;
Expand Down
8 changes: 5 additions & 3 deletions src/controller-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default class ControllerManager {

/**
* @member
* Docker-compose executable path.
* Docker compose executable path.
*/
private readonly dockerComposeBin: string = 'docker-compose'
private readonly dockerComposeBin: string = 'docker compose'

/**
* @member
Expand Down Expand Up @@ -236,6 +236,8 @@ export default class ControllerManager {
ce_dev_controller: {
container_name: 'ce_dev_controller',
image: 'codeenigma/ce-dev-controller-1.x:latest',
platform: 'linux/amd64',
cgroup: 'host',
hostname: 'ce_dev_controller',
networks: {
ce_dev: {
Expand All @@ -248,7 +250,7 @@ export default class ControllerManager {
'ce_dev_apt_cache:/var/cache/apt/archives',
'ce_dev_composer_cache:/home/ce-dev/.composer/cache',
'ce_dev_nvm_node:/home/ce-dev/.nvm/versions/node',
'/sys/fs/cgroup:/sys/fs/cgroup:ro',
'/sys/fs/cgroup:/sys/fs/cgroup:rw',
this.config.cacheDir + ':/home/ce-dev/.ce-dev-cache',
],
},
Expand Down
2 changes: 2 additions & 0 deletions templates/blank/ce-dev/ce-dev.compose.prebuilt.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ x-ce_dev:
services:
{{ project_name }}:
image: 'codeenigma/blank-blank:latest'
platform: linux/amd64
cgroup: host
cap_add:
- NET_ADMIN
x-ce_dev:
Expand Down
4 changes: 3 additions & 1 deletion templates/blank/ce-dev/ce-dev.compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"
x-ce_dev:
registry: localhost:5000
project_name: {{ project_name }}
provision:
provision:
- ce-dev/ansible/provision.yml
deploy:
- ce-dev/ansible/deploy.yml
Expand All @@ -11,6 +11,8 @@ x-ce_dev:
services:
{{ project_name }}:
image: codeenigma/ce-dev-1.x:latest
platform: linux/amd64
cgroup: host
cap_add:
- NET_ADMIN
x-ce_dev:
Expand Down
4 changes: 2 additions & 2 deletions templates/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
command: git init
args:
chdir: "/home/ce-dev/.ce-dev-cache/{{ project_name }}"
- name: Generate docker-compose template.
- name: Generate docker compose template.
template:
src: "{{ project_type }}/ce-dev/ce-dev.compose.yml.j2"
dest: "/home/ce-dev/.ce-dev-cache/{{ project_name }}/ce-dev/ce-dev.compose.yml"
- name: Generate docker-compose prebuilt template.
- name: Generate docker compose prebuilt template.
template:
src: "{{ project_type }}/ce-dev/ce-dev.compose.prebuilt.yml.j2"
dest: "/home/ce-dev/.ce-dev-cache/{{ project_name }}/ce-dev/ce-dev.compose.prebuilt.yml"
Expand Down
2 changes: 1 addition & 1 deletion templates/drupal8/ce-dev/ansible/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- _env_type: dev
{% raw %}
- _domain_name: www.{{ project_name }}.local
# Path to your project root. This must match the "volume" set in the docker-compose template.
# Path to your project root. This must match the "volume" set in the docker compose template.
- deploy_path: /home/ce-dev/deploy/live.local
# This actually does not take any backup, but is needed to populate settings.php.
- mysql_backup:
Expand Down
Loading