Fix env variables
This commit is contained in:
parent
4822a1955a
commit
4e0b64e506
3 changed files with 51 additions and 0 deletions
|
@ -1,2 +1,6 @@
|
||||||
FROM gitea/gitea:1.16.9
|
FROM gitea/gitea:1.16.9
|
||||||
|
|
||||||
|
COPY entrypoint-wrapper parse-database-url /usr/bin/
|
||||||
|
RUN chmod 755 /usr/bin/entrypoint-wrapper /usr/bin/parse-database-url
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/entrypoint-wrapper"]
|
||||||
|
|
12
entrypoint-wrapper
Executable file
12
entrypoint-wrapper
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# vim: set ts=2 sw=2 et ft=bash:
|
||||||
|
|
||||||
|
eval "$(/usr/bin/parse-database-url "${DATABASE_URL:-}" GITEA__database__ |sed -e 's/^/export /')"
|
||||||
|
|
||||||
|
# Rename variables
|
||||||
|
GITEA__database__DB_TYPE="$GITEA__database__PROTO"
|
||||||
|
GITEA__database__PASSWD="$GITEA__database__PASS"
|
||||||
|
export GITEA__database__DB_TYPE
|
||||||
|
export GITEA__database__PASSWD
|
||||||
|
|
||||||
|
exec /usr/bin/entrypoint "$@"
|
35
parse-database-url
Executable file
35
parse-database-url
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Referenced and tweaked from http://stackoverflow.com/questions/6174220/parse-url-in-shell-script#6174447
|
||||||
|
|
||||||
|
url="$1"
|
||||||
|
prefix="$2"
|
||||||
|
proto="$(echo "$url" | grep :// | sed -e 's,^\(.*\)://.*,\1,g')"
|
||||||
|
# remove the protocol
|
||||||
|
workurl="$(echo "$url" |sed -e "s,^$proto://,,")"
|
||||||
|
# extract the user (if any)
|
||||||
|
userpass="$(echo "$workurl" | grep @ | cut -d@ -f1)"
|
||||||
|
pass="$(echo "$userpass"| grep : | cut -d: -f2)"
|
||||||
|
if [ -n "$pass" ]; then
|
||||||
|
user="$(echo "$userpass" | grep : | cut -d: -f1)"
|
||||||
|
else
|
||||||
|
user="$userpass"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# extract the host
|
||||||
|
hostport="$(echo "$workurl" |sed -e "s,$userpass@,," | cut -d/ -f1)"
|
||||||
|
# by request - try to extract the port
|
||||||
|
port="$(echo "$hostport" | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
|
||||||
|
host="$(echo "$hostport" | cut -d: -f1)"
|
||||||
|
# extract the path (if any)
|
||||||
|
path="/$(echo "$workurl" | grep / | cut -d/ -f2-)"
|
||||||
|
name="$(echo "$workurl" | grep / | cut -d/ -f2-)"
|
||||||
|
|
||||||
|
echo "${prefix}_URL=\"$url\""
|
||||||
|
echo "${prefix}_PROTO=\"$proto\""
|
||||||
|
echo "${prefix}_USER=\"$user\""
|
||||||
|
echo "${prefix}_PASS=\"$pass\""
|
||||||
|
echo "${prefix}_HOST=\"$host\""
|
||||||
|
echo "${prefix}_PORT=\"$port\""
|
||||||
|
echo "${prefix}_PATH=\"$path\""
|
||||||
|
echo "${prefix}_NAME=\"$name\""
|
||||||
|
|
Loading…
Reference in a new issue