docker_stack/entrypoint.sh

28 lines
527 B
Bash

#!/bin/sh
set -e
registry="${PLUGIN_REGISTRY:-$ORG_REGISTRY}"
stack_name="${PLUGIN_NAME:-${DRONE_REPO_NAME:-${CI_REPO_NAME}}}"
compose_file="${PLUGIN_COMPOSE_FILE_PATH:-docker-compose.yml}"
set -x
if [ -n "${registry}" ]; then
auth_flags=--with-registry-auth
fi
if [ -n "$PLUGIN_PASSWORD" ]; then
echo -n "$PLUGIN_PASSWORD" | \
docker login \
-u "$PLUGIN_USERNAME" \
--password-stdin \
${registry}
fi
docker stack deploy \
$auth_flags \
--compose-file "${compose_file}" \
"${stack_name}"