58 lines
1.4 KiB
Bash
58 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
# dxkit/runtime/docker.runtime.sh
|
|
#
|
|
# Docker Compose runtime driver.
|
|
# Implements the runtime:: interface using docker compose.
|
|
|
|
function runtime::docker::up() {
|
|
local args=()
|
|
flag::enabled --recreate && args+=(--force-recreate)
|
|
flag::enabled --build && args+=(--build)
|
|
flag::enabled --foreground || args+=(-d)
|
|
|
|
docker::compose::up "${args[@]+"${args[@]}"}"
|
|
}
|
|
|
|
function runtime::docker::down() {
|
|
local args=()
|
|
flag::enabled --volumes && args+=(--volumes)
|
|
flag::enabled --orphans && args+=(--remove-orphans)
|
|
|
|
docker::compose::down "${args[@]+"${args[@]}"}"
|
|
}
|
|
|
|
function runtime::docker::logs() {
|
|
local args=()
|
|
flag::enabled --follow && args+=(-f)
|
|
|
|
docker::compose::logs "${args[@]+"${args[@]}"}"
|
|
}
|
|
|
|
function runtime::docker::list() {
|
|
docker::list_containers
|
|
}
|
|
|
|
function runtime::docker::status() {
|
|
docker::compose::ps --format "table {{.Name}}\t{{.Status}}\t{{.Ports}}"
|
|
}
|
|
|
|
function runtime::docker::build() {
|
|
docker::compose::build "$@"
|
|
}
|
|
|
|
function runtime::docker::ensure() {
|
|
docker::compose::ensure_running
|
|
}
|
|
|
|
function runtime::docker::is_inside() {
|
|
docker::inside_container
|
|
}
|
|
|
|
function runtime::docker::exec() {
|
|
docker::compose::exec "$(runtime::service)" "$@"
|
|
}
|
|
|
|
function runtime::docker::shell() {
|
|
docker::compose::exec -it "$(runtime::service)" bash 2>/dev/null \
|
|
|| docker::compose::exec -it "$(runtime::service)" sh
|
|
}
|