Skip to content

Commit fea4aeb

Browse files
committed
Added supervisord and added auto start of referenced containers (databases)
1 parent cc8f123 commit fea4aeb

26 files changed

Lines changed: 244 additions & 45 deletions

File tree

‎dokku‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ case "$1" in
7777
port=$(docker port $id 5000 | sed 's/0.0.0.0://')
7878
echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL"
7979

80-
# start the worker
81-
DOCKER_ARGS="$(: | pluginhook docker-args "$APP" worker)"
82-
docker run -d --name="$APP_WORKER_NAME" $DOCKER_ARGS "$IMAGE_GENERIC:latest" /bin/bash -c "/start worker" > /dev/null
83-
8480
# finish deployment
8581
pluginhook post-deploy "$APP" "$port"
8682

@@ -115,7 +111,9 @@ case "$1" in
115111
deploy:all)
116112
for app in $(ls -d $DOKKU_ROOT/*/); do
117113
APP="$(basename $app)"
118-
dokku deploy "$APP"
114+
if [[ -f "$app/refs/heads/master" ]]; then
115+
dokku deploy "$APP"
116+
fi
119117
done
120118
;;
121119

‎plugins/docker-args/docker-args‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ case "$2" in
1818
print_args "DOCKER_ARGS_WEB"
1919
;;
2020

21-
worker)
22-
print_args "DOCKER_ARGS"
23-
print_args "DOCKER_ARGS_WORKER"
24-
;;
25-
2621
run)
2722
print_args "DOCKER_ARGS"
2823
;;

‎plugins/dokku-mariadb/install‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ if [[ ! -f "$DB_ADMIN_PASSWORD" ]]; then
1717
fi
1818

1919
stop_and_remove_container "$DB_CONTAINER"
20-
21-
docker run --detach "--publish=$DB_PORT" \
22-
--volume="$DB_VOLUME":"$DB_CONTAINER_VOLUME" \
23-
--volume="$DB_ADMIN_PASSWORD":"$DB_CONTAINER_PASSWORD" \
24-
--name="$DB_CONTAINER" \
25-
"$DB_IMAGE" \
26-
/usr/bin/start_mariadb.sh >/dev/null
20+
ensure_database_container_is_running
2721

2822
cat

‎plugins/dokku-mariadb/post-release‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if [[ -d "$DB_LINKS" ]] && [[ -f "$DB_APP_PASSWORD" ]] && [[ $(ls -1 "$DB_LINKS"
1313
docker run -i -a stdin "$IMAGE" /bin/bash -c "cat > /app/.profile.d/mariadb_env" <<EOF | commit_image "$IMAGE"
1414
[ "\$MARIADB_NAME" != "" ] && export DATABASE_URL=mysql2://$APP:$(cat "$DB_APP_PASSWORD")@\$MARIADB_PORT_3306_TCP_ADDR:\$MARIADB_PORT_3306_TCP_PORT/$DB_NAME
1515
EOF
16-
verbose "Linking MariaDB database $DB_NAME to application" 1>&2
16+
verbose "Linking MariaDB database $DB_NAME to application"
1717
done
1818
fi

‎plugins/dokku-mariadb/pre-build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if [[ -d "$DB_LINKS" ]] && [[ -f "$DB_APP_PASSWORD" ]] && [[ $(ls -1 "$DB_LINKS"
1313
docker run -i -a stdin "$IMAGE" /bin/bash -c "cat >> /app/.env" <<EOF | commit_image "$IMAGE"
1414
[ "\$MARIADB_NAME" != "" ] && export DATABASE_URL=mysql2://$APP:$(cat "$DB_APP_PASSWORD")@\$MARIADB_PORT_3306_TCP_ADDR:\$MARIADB_PORT_3306_TCP_PORT/$DB_NAME
1515
EOF
16-
verbose "Linking MariaDB database $DB_NAME to application" 1>&2
16+
verbose "Linking MariaDB database $DB_NAME to application"
1717
done
1818
fi

‎plugins/dokku-mariadb/pre-deploy‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
source "$(dirname $0)/vars"
4+
5+
verify_app_name "$1"
6+
7+
DB_LINKS="$DB_APP_DATABASES$APP/"
8+
DB_APP_PASSWORD="$DB_APP_PASSWORDS$APP"
9+
10+
# inject MARIADB_URL
11+
if [[ -d "$DB_LINKS" ]] && [[ -f "$DB_APP_PASSWORD" ]] && [[ $(ls -1 "$DB_LINKS" | wc -l) -gt 0 ]]; then
12+
ls -1 "$DB_LINKS" | while read DB_NAME; do
13+
ensure_database_container_is_running
14+
break
15+
done
16+
fi

‎plugins/dokku-mariadb/vars‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,16 @@ DB_PORT=3306
1414

1515
DB_APP_PASSWORDS="$DB_ROOT/pwd_app_"
1616
DB_APP_DATABASES="$DB_ROOT/dbs_app_"
17+
18+
function ensure_database_container_is_running() {
19+
# remove it silently
20+
remove_container "$DB_CONTAINER"
21+
22+
# and start detached
23+
docker run --detach "--publish=$DB_PORT" \
24+
--volume="$DB_VOLUME":"$DB_CONTAINER_VOLUME" \
25+
--volume="$DB_ADMIN_PASSWORD":"$DB_CONTAINER_PASSWORD" \
26+
--name="$DB_CONTAINER" \
27+
"$DB_IMAGE" \
28+
/usr/bin/start_mariadb.sh >/dev/null
29+
}

‎plugins/dokku-mongodb/install‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ if [[ ! -f "$DB_ADMIN_PASSWORD" ]]; then
1717
fi
1818

1919
stop_and_remove_container "$DB_CONTAINER"
20-
21-
docker run --detach "--publish=$DB_PORT" \
22-
--volume="$DB_VOLUME":"$DB_CONTAINER_VOLUME" \
23-
--volume="$DB_ADMIN_PASSWORD":"$DB_CONTAINER_PASSWORD" \
24-
--name="$DB_CONTAINER" \
25-
"$DB_IMAGE" \
26-
/usr/bin/start_mongodb.sh >/dev/null
20+
ensure_database_container_is_running
2721

2822
cat

‎plugins/dokku-mongodb/post-release‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if [[ -d "$DB_LINKS" ]] && [[ -f "$DB_APP_PASSWORD" ]] && [[ $(ls -1 "$DB_LINKS"
1313
docker run -i -a stdin "$IMAGE" /bin/bash -c "cat > /app/.profile.d/mongodb_env" <<EOF | commit_image "$IMAGE"
1414
[ "\$MONGODB_NAME" != "" ] && export MONGODB_URL=mongodb://$APP:$(cat "$DB_APP_PASSWORD")@\$MONGODB_PORT_${DB_PORT}_TCP_ADDR:\$MONGODB_PORT_${DB_PORT}_TCP_PORT/$DB_NAME
1515
EOF
16-
verbose "Linking MongoDB database $DB_NAME to application" 1>&2
16+
verbose "Linking MongoDB database $DB_NAME to application"
1717
done
1818
fi

‎plugins/dokku-mongodb/pre-build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if [[ -d "$DB_LINKS" ]] && [[ -f "$DB_APP_PASSWORD" ]] && [[ $(ls -1 "$DB_LINKS"
1313
docker run -i -a stdin "$IMAGE" /bin/bash -c "cat >> /app/.env" <<EOF | commit_image "$IMAGE"
1414
[ "\$MONGODB_NAME" != "" ] && export MONGODB_URL=mongodb://$APP:$(cat "$DB_APP_PASSWORD")@\$MONGODB_PORT_${DB_PORT}_TCP_ADDR:\$MONGODB_PORT_${DB_PORT}_TCP_PORT/$DB_NAME
1515
EOF
16-
verbose "Linking MongoDB database $DB_NAME to application" 1>&2
16+
verbose "Linking MongoDB database $DB_NAME to application"
1717
done
1818
fi

0 commit comments

Comments
 (0)