docker_stack/entrypoint.sh

28 lines
527 B
Bash
Raw Normal View History

2022-06-06 16:46:25 +03:00
#!/bin/sh
2023-03-15 12:32:36 +03:00
set -e
2022-06-06 16:46:25 +03:00
2023-03-15 12:32:36 +03:00
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
2023-03-09 15:16:51 +03:00
fi
2022-06-06 16:46:25 +03:00
if [ -n "$PLUGIN_PASSWORD" ]; then
2022-06-07 14:59:39 +03:00
echo -n "$PLUGIN_PASSWORD" | \
docker login \
-u "$PLUGIN_USERNAME" \
--password-stdin \
2023-03-15 12:32:36 +03:00
${registry}
2022-06-06 16:46:25 +03:00
fi
2023-03-15 16:21:13 +03:00
docker stack deploy \
2023-03-15 12:32:36 +03:00
$auth_flags \
--compose-file "${compose_file}" \
"${stack_name}"
2022-06-06 16:46:25 +03:00