Some checks failed
Test and Publish Templates / test-and-publish (push) Failing after 11s
37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
source "${AGENT_PATH}/common.sh"
|
|
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "DATA_PATH" "CONFIG_PATH" "REGISTRY_PORT"
|
|
|
|
# START SCRIPT
|
|
# The start script is required for all templates.
|
|
# It is used to start the service on the server.
|
|
|
|
if [ ! -f "${CONFIG_PATH}/htpasswd" ]; then
|
|
_die "htpasswd file not found in ${CONFIG_PATH}/htpasswd - see README.txt for instructions"
|
|
fi
|
|
|
|
# Create data directory if it doesn't exist
|
|
_create_folder "${DATA_PATH}"
|
|
|
|
DOCKER_RUN_CMD="docker run -d \
|
|
--restart unless-stopped \
|
|
--name ${CONTAINER_NAME} \
|
|
-p ${REGISTRY_PORT}:5000 \
|
|
-v ${DATA_PATH}:/var/lib/registry \
|
|
-v ${CONFIG_PATH}/htpasswd:/auth/htpasswd:ro \
|
|
-e REGISTRY_AUTH=htpasswd \
|
|
-e REGISTRY_AUTH_HTPASSWD_REALM=Registry \
|
|
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
|
|
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
|
|
|
|
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
|
|
_die "Failed to start container ${CONTAINER_NAME}"
|
|
fi
|
|
|
|
# Check if the container is running
|
|
if ! _is_container_running "$CONTAINER_NAME"; then
|
|
_die "Container ${CONTAINER_NAME} is not running"
|
|
fi
|
|
|
|
echo "Container ${CONTAINER_NAME} started on port ${REGISTRY_PORT}"
|