Merge pull request #773 from mwxp06/develop

Added docker environment variable SEMAPHORE_DB_DIALECT
This commit is contained in:
Denis Gukov 2021-10-30 00:59:53 +05:00 committed by GitHub
commit fcf44e3f6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View File

@ -20,6 +20,7 @@ services:
context: ./../../../ context: ./../../../
dockerfile: ./deployment/docker/ci/Dockerfile dockerfile: ./deployment/docker/ci/Dockerfile
environment: environment:
SEMAPHORE_DB_DIALECT: mysql
SEMAPHORE_DB_USER: semaphore SEMAPHORE_DB_USER: semaphore
SEMAPHORE_DB_PASS: semaphore SEMAPHORE_DB_PASS: semaphore
SEMAPHORE_DB_HOST: mysql SEMAPHORE_DB_HOST: mysql

View File

@ -8,6 +8,8 @@ SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
SEMAPHORE_TMP_PATH="${SEMAPHORE_TMP_PATH:-/tmp/semaphore}" SEMAPHORE_TMP_PATH="${SEMAPHORE_TMP_PATH:-/tmp/semaphore}"
# Semaphore database env config # 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_HOST="${SEMAPHORE_DB_HOST:-0.0.0.0}"
SEMAPHORE_DB_PORT="${SEMAPHORE_DB_PORT:-3306}" SEMAPHORE_DB_PORT="${SEMAPHORE_DB_PORT:-3306}"
SEMAPHORE_DB="${SEMAPHORE_DB:-semaphore}" SEMAPHORE_DB="${SEMAPHORE_DB:-semaphore}"
@ -48,7 +50,7 @@ SEMAPHORE_LDAP_MAPPING_EMAIL="${SEMAPHORE_LDAP_MAPPING_EMAIL:-mail}"
# wait on db to be up # 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} ..." echoerr "Attempting to connect to database ${SEMAPHORE_DB} on ${SEMAPHORE_DB_HOST}:${SEMAPHORE_DB_PORT} with user ${SEMAPHORE_DB_USER} ..."
TIMEOUT=30 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) TIMEOUT=$(expr $TIMEOUT - 1)
if [ $TIMEOUT -eq 0 ]; then if [ $TIMEOUT -eq 0 ]; then
echoerr "Could not connect to database server. Exiting." 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 sleep 1
done 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 # Create a config if it does not exist in the current config path
if [ ! -f "${SEMAPHORE_CONFIG_PATH}/config.json" ]; then if [ ! -f "${SEMAPHORE_CONFIG_PATH}/config.json" ]; then
echoerr "Generating ${SEMAPHORE_TMP_PATH}/config.stdin ..." echoerr "Generating ${SEMAPHORE_TMP_PATH}/config.stdin ..."
cat << EOF > "${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_HOST}:${SEMAPHORE_DB_PORT}
${SEMAPHORE_DB_USER} ${SEMAPHORE_DB_USER}
${SEMAPHORE_DB_PASS} ${SEMAPHORE_DB_PASS}

View File

@ -22,6 +22,7 @@ services:
volumes: volumes:
- "./../../../:/go/src/github.com/ansible-semaphore/semaphore:rw" - "./../../../:/go/src/github.com/ansible-semaphore/semaphore:rw"
environment: environment:
SEMAPHORE_DB_DIALECT: mysql
SEMAPHORE_DB_USER: semaphore SEMAPHORE_DB_USER: semaphore
SEMAPHORE_DB_PASS: semaphore SEMAPHORE_DB_PASS: semaphore
SEMAPHORE_DB_HOST: mysql SEMAPHORE_DB_HOST: mysql

View File

@ -18,6 +18,7 @@ services:
context: ./../../../ context: ./../../../
dockerfile: ./deployment/docker/prod/Dockerfile dockerfile: ./deployment/docker/prod/Dockerfile
environment: environment:
SEMAPHORE_DB_DIALECT: mysql
SEMAPHORE_DB_USER: semaphore SEMAPHORE_DB_USER: semaphore
SEMAPHORE_DB_PASS: hx4hjxqthfwbfsy5535u4agfdscm SEMAPHORE_DB_PASS: hx4hjxqthfwbfsy5535u4agfdscm
SEMAPHORE_DB_HOST: mysql SEMAPHORE_DB_HOST: mysql