Browse Source

new: pkg: avoid spurious warnings from ``docker-compose run`` calls.

This helps charm direct actions to keep a tidy standard output, and allows
them to be used in scripts.

``docker-compose`` was updated to the latest version available (aka
``1.24.0``) and was patched to include what might have been forgotten
when implementing the ``COMPOSE_IGNORE_ORPHANS`` environment variable.

On ``compose`` side, we need to make sure to pass environment variables
that are to be used by ``docker-compose``.

PR: https://github.com/docker/compose/pull/7020
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
test1
Valentin Lab 5 years ago
parent
commit
8c756c562e
  1. 8
      Dockerfile
  2. 36
      bin/compose

8
Dockerfile

@ -22,7 +22,7 @@ ENV KAL_SHLIB_ARRAY_VERSION="0.2.0" \
KAL_SHLIB_PRETTY_VERSION="0.4.3" KAL_SHLIB_PRETTY_VERSION="0.4.3"
ARG DOCKER_CLI_VERSION="17.06.2-ce" ARG DOCKER_CLI_VERSION="17.06.2-ce"
ARG DOCKER_COMPOSE_VERSION="1.21.2"
ARG DOCKER_COMPOSE_VERSION="1.24.0"
## install docker ## install docker
ENV DOCKER_DOWNLOAD_URL="https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLI_VERSION.tgz" ENV DOCKER_DOWNLOAD_URL="https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLI_VERSION.tgz"
@ -58,7 +58,11 @@ RUN apk add yaml-dev cython cython-dev && \
RUN pip install crudini RUN pip install crudini
RUN pip install docker-compose==$DOCKER_COMPOSE_VERSION
RUN apk add libffi-dev openssl-dev && \
pip install pip==19.3.1 cffi==1.12.3 \
git+https://github.com/0k/compose@run_ignore_orphans
# docker-compose==$DOCKER_COMPOSE_VERSION
# pip install git+https://github.com/vaab/colour@master
RUN curl -L https://git.0k.io/0k-charm.git/plain/bin/charm > /usr/local/bin/charm && \ RUN curl -L https://git.0k.io/0k-charm.git/plain/bin/charm > /usr/local/bin/charm && \
chmod +x /usr/local/bin/charm chmod +x /usr/local/bin/charm

36
bin/compose

@ -35,6 +35,30 @@ read-0() {
} }
read-0a() {
local eof= IFS=''
while [ "$1" ]; do
IFS='' read -r -d $'\n' -- "$1" || eof=1
shift
done
[ -z "$eof" ]
}
p0() {
printf "%s\0" "$@"
}
list_compose_vars() {
while read-0a def; do
def="${def##* }"
def="${def%=*}"
p0 "$def"
done < <(declare -p | grep "^declare -x COMPOSE_[A-Z_]\+=\"")
}
get_running_compose_containers() { get_running_compose_containers() {
## XXXvlab: docker bug: there will be a final newline anyway ## XXXvlab: docker bug: there will be a final newline anyway
docker ps --filter label="compose.service" --format='{{.ID}}' docker ps --filter label="compose.service" --format='{{.ID}}'
@ -188,6 +212,18 @@ mk_docker_run_options() {
COMPOSE_LAUNCHER_BIN=$(readlink -f "${BASH_SOURCE[0]}") COMPOSE_LAUNCHER_BIN=$(readlink -f "${BASH_SOURCE[0]}")
docker_run_opts+=("-v" "$COMPOSE_LAUNCHER_BIN:/usr/local/bin/compose") docker_run_opts+=("-v" "$COMPOSE_LAUNCHER_BIN:/usr/local/bin/compose")
while read-0 var; do
case "$var" in
COMPOSE_YML_FILE|COMPOSE_LAUNCHER_BIN|COMPOSE_DOCKER_IMAGE|\
COMPOSE_LAUNCHER_OPTS|COMPOSE_VAR|COMPOSE_CACHE)
:
;;
*)
docker_run_opts+=("-e" "$var=${!var}")
;;
esac
done < <(list_compose_vars)
filename=$(mktemp -p /tmp/ -t launch_opts-XXXXXXXXXXXXXXXX) filename=$(mktemp -p /tmp/ -t launch_opts-XXXXXXXXXXXXXXXX)
{ {
printf "%s\0" "${docker_run_opts[@]}" printf "%s\0" "${docker_run_opts[@]}"

Loading…
Cancel
Save