Two mechanisms, matching what the make engine actually did:
Lazy defaults. A stack setting is a function myos_default_<VAR>, called only
when the variable has no value, and called again at every reference. That is
exactly a recursive ?=: an explicit value wins, and the default follows a
DOMAIN that a .env changes later. The prefix is what makes it safe; the first
version used a bare function named after the variable, and the test suite
caught it running /usr/bin/host for a stack group called host.
Templates. myos env-update fills a .env from the .env.dist files, expanding
${VAR} against the current values and running $(command), forward references
included.
Also fixed: the project .env now wins over /etc/conf.d/myos, which is what the
documentation claimed and the code did not.
share/make/shim.mk lets a project keep make as a front end: every myos command
becomes a target that shells out to bin/myos, and the project keeps its own
targets and its stack .mk files. It sits outside make/ because the legacy
engine globs every .mk in there.
2.4 KiB
2.4 KiB
Commands
myos [options] <command> [stack...] [VAR=value...] [-- args...]
| option | effect |
|---|---|
-C DIR |
work in DIR instead of the current directory |
-e ENV |
environment: picks .env.<env> and the <stack>.<env>.yml overlays |
-n, --dry-run |
print the commands instead of running them |
-v, --verbose |
say what myos is doing |
-d, --debug |
print every command |
| command | effect |
|---|---|
up |
create and start; creates the external networks first |
down |
remove the containers |
start / stop / restart |
on the existing containers |
ps |
what is running |
logs |
follow the logs |
config |
the resolved compose file |
exec |
run a command in a running service |
run |
run it in a new container, removed afterwards |
scale |
myos scale <stack> SERVICE=<name> NUM=<n> |
build / pull |
images |
ls [--groups] |
the stacks and groups myos can see |
env [VAR...] |
resolved variables |
env-update |
fill the .env from the .env.dist templates |
doctor |
check the installation |
version |
the myos version |
Anything after -- goes to docker compose:
myos logs host/fabio -- --tail 20
myos up postgres -- --force-recreate
exec and run take the service from the stack name, since most stacks name
their main service after themselves. SERVICE= picks another one:
myos exec host/consul -- consul members # service consul, command "consul members"
myos exec host/fabio SERVICE=fabio -- sh
myos run postgres -- psql -l
Exit codes
| code | meaning |
|---|---|
| 0 | fine |
| 1 | the command failed |
| 2 | bad invocation, or an unknown command |
| 3 | stack not found (the message prints the search path) |
| 4 | missing requirement, run myos doctor |
The make engine exited 0 on an unknown target, printing only a warning. The CLI does not: a typo is an error.
Coming from the make targets
| make | myos |
|---|---|
make up STACK=host |
myos up host |
make print-COMPOSE_FILE |
myos env COMPOSE_FILE |
make host |
myos up host |
make stack-host-config |
myos config host |
make up@master |
myos -e master up |
make exec SERVICE=php ARGS='ls' |
myos exec <stack> -- php ls |
make DRYRUN=true up |
myos -n up |
print-VAR, stack-<stack>-<command> and <command>@<env> still work.
A project Makefile that includes make/include.mk keeps working too.