diff --git a/deployment/docker/ci/docker-compose.yml b/deployment/docker/ci/docker-compose.yml index 32cee642..3c3b4b57 100644 --- a/deployment/docker/ci/docker-compose.yml +++ b/deployment/docker/ci/docker-compose.yml @@ -20,6 +20,7 @@ services: context: ./../../../ dockerfile: ./deployment/docker/ci/Dockerfile environment: + SEMAPHORE_DB_DIALECT: mysql SEMAPHORE_DB_USER: semaphore SEMAPHORE_DB_PASS: semaphore SEMAPHORE_DB_HOST: mysql diff --git a/deployment/docker/common/semaphore-wrapper b/deployment/docker/common/semaphore-wrapper index d037ca1c..bec1768e 100755 --- a/deployment/docker/common/semaphore-wrapper +++ b/deployment/docker/common/semaphore-wrapper @@ -8,6 +8,8 @@ SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}" SEMAPHORE_TMP_PATH="${SEMAPHORE_TMP_PATH:-/tmp/semaphore}" # Semaphore database env config +SEMAPHORE_DB_DIALECT="${SEMAPHORE_DB_DIALECT:-mysql}" +SEMAPHORE_DB_DIALECT_ID=1 SEMAPHORE_DB_HOST="${SEMAPHORE_DB_HOST:-0.0.0.0}" SEMAPHORE_DB_PORT="${SEMAPHORE_DB_PORT:-3306}" SEMAPHORE_DB="${SEMAPHORE_DB:-semaphore}" @@ -48,7 +50,7 @@ SEMAPHORE_LDAP_MAPPING_EMAIL="${SEMAPHORE_LDAP_MAPPING_EMAIL:-mail}" # wait on db to be up echoerr "Attempting to connect to database ${SEMAPHORE_DB} on ${SEMAPHORE_DB_HOST}:${SEMAPHORE_DB_PORT} with user ${SEMAPHORE_DB_USER} ..." TIMEOUT=30 -while ! mysqladmin ping -h"$SEMAPHORE_DB_HOST" -P "$SEMAPHORE_DB_PORT" -u "$SEMAPHORE_DB_USER" --password="$SEMAPHORE_DB_PASS" --silent >/dev/null 2>&1; do +while ! $(nc -z "$SEMAPHORE_DB_HOST" "$SEMAPHORE_DB_PORT") >/dev/null 2>&1; do TIMEOUT=$(expr $TIMEOUT - 1) if [ $TIMEOUT -eq 0 ]; then echoerr "Could not connect to database server. Exiting." @@ -58,11 +60,17 @@ while ! mysqladmin ping -h"$SEMAPHORE_DB_HOST" -P "$SEMAPHORE_DB_PORT" -u "$SEMA sleep 1 done +case ${SEMAPHORE_DB_DIALECT} in + "mysql") SEMAPHORE_DB_DIALECT_ID=1;; + "bolt") SEMAPHORE_DB_DIALECT_ID=2;; + "postgres") SEMAPHORE_DB_DIALECT_ID=3;; +esac + # Create a config if it does not exist in the current config path if [ ! -f "${SEMAPHORE_CONFIG_PATH}/config.json" ]; then echoerr "Generating ${SEMAPHORE_TMP_PATH}/config.stdin ..." cat << EOF > "${SEMAPHORE_TMP_PATH}/config.stdin" -1 +${SEMAPHORE_DB_DIALECT_ID} ${SEMAPHORE_DB_HOST}:${SEMAPHORE_DB_PORT} ${SEMAPHORE_DB_USER} ${SEMAPHORE_DB_PASS} diff --git a/deployment/docker/dev/docker-compose.yml b/deployment/docker/dev/docker-compose.yml index f03b1e715..abb13db6 100644 --- a/deployment/docker/dev/docker-compose.yml +++ b/deployment/docker/dev/docker-compose.yml @@ -22,6 +22,7 @@ services: volumes: - "./../../../:/go/src/github.com/ansible-semaphore/semaphore:rw" environment: + SEMAPHORE_DB_DIALECT: mysql SEMAPHORE_DB_USER: semaphore SEMAPHORE_DB_PASS: semaphore SEMAPHORE_DB_HOST: mysql diff --git a/deployment/docker/prod/docker-compose.yml b/deployment/docker/prod/docker-compose.yml index a817e362..578536e4 100644 --- a/deployment/docker/prod/docker-compose.yml +++ b/deployment/docker/prod/docker-compose.yml @@ -18,6 +18,7 @@ services: context: ./../../../ dockerfile: ./deployment/docker/prod/Dockerfile environment: + SEMAPHORE_DB_DIALECT: mysql SEMAPHORE_DB_USER: semaphore SEMAPHORE_DB_PASS: hx4hjxqthfwbfsy5535u4agfdscm SEMAPHORE_DB_HOST: mysql