Go for the postdeploy.sh approach
This commit is contained in:
parent
88ac6e9526
commit
4c8fe79dbe
@ -2,4 +2,7 @@ FROM gitea/gitea:1.11.2
|
|||||||
|
|
||||||
COPY . ${WORKDIR}
|
COPY . ${WORKDIR}
|
||||||
|
|
||||||
|
RUN mkdir -p /app/
|
||||||
|
COPY postdeploy.sh /app/
|
||||||
|
|
||||||
EXPOSE 80:3000
|
EXPOSE 80:3000
|
||||||
|
3
app.json
3
app.json
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitea",
|
"name": "gitea",
|
||||||
"description": "Gitea is a painless self-hosted Git service.",
|
"description": "Gitea is a painless self-hosted Git service.",
|
||||||
"repository": "https://gitlab.com/autonomic-cooperative/gitea-dokku"
|
"repository": "https://gitlab.com/autonomic-cooperative/gitea-dokku",
|
||||||
|
"scripts": { "dokku": { "postdeploy": "bash /app/postdeploy.sh" } }
|
||||||
}
|
}
|
||||||
|
44
postdeploy.sh
Executable file
44
postdeploy.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
setup_root_user() {
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# TODO(decentral1se): fix to use sqlite3 database for now
|
||||||
|
user_count=$(mysql -u"${DB_USER}" -p"${DB_PASS}" -h mysql --database="${DB_NAME}" -N -B -e "SELECT count(*) FROM user;")
|
||||||
|
|
||||||
|
if [[ "${user_count}" == "0" ]]; then
|
||||||
|
echo "==> Setting up root user for first run"
|
||||||
|
|
||||||
|
if gitea create-admin --name "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL"; then
|
||||||
|
echo "==> root user added"
|
||||||
|
else
|
||||||
|
echo "==> Failed to add root user"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_healthcheck() {
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "==> Running Gitea healthcheck"
|
||||||
|
|
||||||
|
while ! curl --fail "https://${DOMAIN}/healthcheck"; do
|
||||||
|
echo "==> Waiting for Gitea to come up"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "==> Gitea is up"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
do_healthcheck
|
||||||
|
setup_root_user
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO(decentral1se): test manually for now...
|
||||||
|
# main
|
Reference in New Issue
Block a user