PTU5KAS/docker-entrypoint
Jan Kiszka 6f51c33be2 Docker: Respect --workdir passed to docker run
This avoids

    docker run ... kasproject/kas sh -c "cd /somepath; kas build ..."

and rather allows for

    docker run ... --workdir=/somepath kasproject/kas build ...

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2018-07-19 09:25:34 +02:00

46 lines
863 B
Bash
Executable File

#!/bin/bash
if mount | grep -q "on / type aufs"; then
cat <<EOF >&2
WARNING: Generation of wic images will fail!
Your docker host setup uses broken aufs as storage driver. Adjust the docker
configuration to use a different driver (overlay, overlay2, devicemapper). You
may also need to update the host distribution (e.g. Debian Jessie -> Stretch).
EOF
fi
USER_ID=${USER_ID:-30000}
if [ $USER_ID == 0 ]; then
# We shall run everything as root
mkdir -p /builder
GOSU=""
else
if ! id $USER_ID >/dev/null 2>&1; then
# Create a non-root user that will perform the actual build
useradd --uid $USER_ID --create-home --home-dir /builder builder
fi
GOSU="gosu builder"
fi
if [ "$PWD" = / ]; then
cd /builder
fi
if [ -n "$1" ]; then
case "$1" in
build|shell|-*)
exec $GOSU kas "$@"
;;
*)
exec $GOSU "$@"
;;
esac
else
exec $GOSU bash
fi