2023-02-28 20:05:08 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
2023-02-28 21:17:50 +01:00
|
|
|
# Copyright 2023 actions-toolkit authors
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2023-02-28 20:05:08 +01:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
: "${TOOLDIR=}"
|
|
|
|
|
: "${RUNDIR=}"
|
|
|
|
|
: "${DOCKER_HOST=}"
|
|
|
|
|
|
|
|
|
|
export PATH="$TOOLDIR::$PATH"
|
|
|
|
|
|
|
|
|
|
if [ -z "$DOCKER_HOST" ]; then
|
|
|
|
|
echo >&2 'error: DOCKER_HOST required'
|
|
|
|
|
false
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! command -v dockerd &> /dev/null; then
|
|
|
|
|
echo >&2 'error: dockerd missing from PATH'
|
|
|
|
|
false
|
|
|
|
|
fi
|
|
|
|
|
|
2023-02-28 20:15:33 +01:00
|
|
|
mkdir -p "$RUNDIR"
|
|
|
|
|
|
2023-02-28 20:05:08 +01:00
|
|
|
(
|
|
|
|
|
echo "Starting dockerd"
|
|
|
|
|
set -x
|
|
|
|
|
exec dockerd \
|
|
|
|
|
--host="$DOCKER_HOST" \
|
|
|
|
|
--exec-root="$RUNDIR/execroot" \
|
|
|
|
|
--data-root="$RUNDIR/data" \
|
|
|
|
|
--pidfile="$RUNDIR/docker.pid" \
|
|
|
|
|
--userland-proxy=false \
|
|
|
|
|
2>&1 | tee "$RUNDIR/dockerd.log"
|
|
|
|
|
) &
|
|
|
|
|
|
|
|
|
|
tries=60
|
|
|
|
|
while ! docker version &> /dev/null; do
|
2023-02-28 20:15:33 +01:00
|
|
|
((tries--))
|
|
|
|
|
if [ $tries -le 0 ]; then
|
|
|
|
|
if [ -z "$DOCKER_HOST" ]; then
|
|
|
|
|
echo >&2 "error: daemon failed to start"
|
|
|
|
|
else
|
|
|
|
|
echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':"
|
|
|
|
|
docker version >&2 || true
|
|
|
|
|
fi
|
|
|
|
|
false
|
|
|
|
|
fi
|
|
|
|
|
sleep 2
|
2023-02-28 20:05:08 +01:00
|
|
|
done
|