36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
# START SCRIPT
|
|
# The start script is required for all templates.
|
|
# It is used to start the service on the server.
|
|
# It is called with the path to the server specific env file as an argument.
|
|
|
|
source "$(dirname "$0")/_common.sh"
|
|
check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "VOLUME_NAME" "WRITE_TOKENS" "CONFIG_PATH"
|
|
|
|
# check volume exists.
|
|
if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then
|
|
die "Docker volume ${VOLUME_NAME} does not exist"
|
|
fi
|
|
|
|
|
|
DOCKER_RUN_CMD="docker run -d \
|
|
--restart unless-stopped \
|
|
--name ${CONTAINER_NAME} \
|
|
-p ${HOST_PORT}:80 \
|
|
-v ${VOLUME_NAME}:/data/storage \
|
|
-v ${CONFIG_PATH}/sos_config.json:/data/sos_config.json:ro \
|
|
${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"
|