|
4 | 4 | lsiown abc:abc \ |
5 | 5 | /config |
6 | 6 |
|
7 | | -lsiown -R abc:abc \ |
8 | | - /app/www/bootstrap/cache \ |
9 | | - /app/www/storage \ |
10 | | - /app/www/database |
11 | | - |
12 | | -if [[ ${DB_CONNECTION:="sqlite"} = "sqlite" ]]; then |
13 | | - # create symlinks |
14 | | - symlinks=( \ |
15 | | - /app/www/database/database.sqlite \ |
16 | | - ) |
17 | | - |
18 | | - for i in "${symlinks[@]}" |
19 | | - do |
20 | | - if [[ -e "$i" && ! -L "$i" ]]; then |
21 | | - rm -rf "$i" |
| 7 | +if [[ "${DB_CONNECTION:=sqlite}" = "sqlite" ]]; then |
| 8 | + touch /config/database.sqlite |
| 9 | + if [[ -e "/app/www/database/database.sqlite" && ! -L "/app/www/database/database.sqlite" ]]; then |
| 10 | + rm -rf "/app/www/database/database.sqlite" |
| 11 | + fi |
| 12 | + if [[ ! -L "/app/www/database/database.sqlite" ]]; then |
| 13 | + ln -s "/config/database.sqlite" "/app/www/database/database.sqlite" |
| 14 | + fi |
| 15 | +elif [[ "${DB_CONNECTION}" = "mysql" ]]; then |
| 16 | + echo "Waiting for DB to be available" |
| 17 | + END=$((SECONDS + 30)) |
| 18 | + while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do |
| 19 | + if [[ $(/usr/bin/nc -w1 "${DB_HOST}" "${DB_PORT}" | tr -d '\0') ]]; then |
| 20 | + if [[ -n "${RUN}" ]]; then |
| 21 | + break |
| 22 | + fi |
| 23 | + RUN="RAN" |
| 24 | + # we sleep here again due to first run init on DB containers |
| 25 | + if [[ ! -f /dbwait.lock ]]; then |
| 26 | + sleep 5 |
| 27 | + fi |
| 28 | + else |
| 29 | + sleep 1 |
22 | 30 | fi |
23 | | - if [[ ! -L "$i" ]]; then |
24 | | - ln -s /config/"$(basename "$i")" "$i" |
| 31 | + done |
| 32 | +elif [[ "${DB_CONNECTION}" = "pgsql" ]]; then |
| 33 | + echo "Waiting for DB to be available" |
| 34 | + END=$((SECONDS + 30)) |
| 35 | + while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do |
| 36 | + if pg_isready -h "${DB_HOST}" -p "${DB_PORT}" -q; then |
| 37 | + if [[ -n "${RUN}" ]]; then |
| 38 | + break |
| 39 | + fi |
| 40 | + RUN="RAN" |
| 41 | + # we sleep here again due to first run init on DB containers |
| 42 | + if [[ ! -f /dbwait.lock ]]; then |
| 43 | + sleep 5 |
| 44 | + fi |
| 45 | + else |
| 46 | + sleep 1 |
25 | 47 | fi |
26 | 48 | done |
27 | 49 | fi |
28 | 50 |
|
| 51 | +lsiown -R abc:abc \ |
| 52 | + /app/www/bootstrap/cache \ |
| 53 | + /app/www/storage \ |
| 54 | + /app/www/database |
| 55 | + |
29 | 56 | # Check for env file |
30 | 57 | if [[ ! -f /config/.env ]]; then |
31 | 58 | cp /app/www/.env.production /config/.env |
|
0 commit comments