Merge pull request #78 from linuxserver/v5-rework

Rework image for v5
This commit is contained in:
Adam 2024-01-09 11:59:23 +00:00 committed by GitHub
commit d4fef27d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 150 additions and 308 deletions

View File

@ -19,6 +19,7 @@ RUN \
exiftool \
ffmpeg \
gd \
grep \
imagemagick \
jpegoptim \
php82-bcmath \
@ -26,15 +27,14 @@ RUN \
php82-exif \
php82-gd \
php82-intl \
php82-mysqli \
php82-pdo_mysql \
php82-pdo_pgsql \
php82-pdo_sqlite \
php82-pecl-imagick \
php82-pecl-redis \
php82-pgsql \
php82-sqlite3 \
php82-tokenizer && \
php82-tokenizer \
postgresql15-client && \
echo "**** configure php-fpm to pass env vars ****" && \
sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php82/php-fpm.d/www.conf && \
grep -qxF 'clear_env = no' /etc/php82/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php82/php-fpm.d/www.conf && \
@ -44,7 +44,11 @@ RUN \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
mkdir -p /app/www && \
git clone --branch "${LYCHEE_VERSION}" --recurse-submodules https://github.com/LycheeOrg/Lychee.git /app/www && \
curl -o \
/tmp/lychee.tar.gz -L \
"https://github.com/LycheeOrg/Lychee/archive/${LYCHEE_VERSION}.tar.gz" && \
tar xf /tmp/lychee.tar.gz -C \
/app/www --strip-components=1 && \
echo "**** install composer dependencies ****" && \
composer install \
-d /app/www \
@ -69,7 +73,8 @@ RUN \
rm -rf \
/tmp/* \
$HOME/.cache \
$HOME/.composer
$HOME/.composer \
$HOME/.npm
# copy local files
COPY root/ /

View File

@ -19,6 +19,7 @@ RUN \
exiftool \
ffmpeg \
gd \
grep \
imagemagick \
jpegoptim \
php82-bcmath \
@ -26,15 +27,14 @@ RUN \
php82-exif \
php82-gd \
php82-intl \
php82-mysqli \
php82-pdo_mysql \
php82-pdo_pgsql \
php82-pdo_sqlite \
php82-pecl-imagick \
php82-pecl-redis \
php82-pgsql \
php82-sqlite3 \
php82-tokenizer && \
php82-tokenizer \
postgresql15-client && \
echo "**** configure php-fpm to pass env vars ****" && \
sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php82/php-fpm.d/www.conf && \
grep -qxF 'clear_env = no' /etc/php82/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php82/php-fpm.d/www.conf && \
@ -44,7 +44,11 @@ RUN \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
mkdir -p /app/www && \
git clone --branch "${LYCHEE_VERSION}" --recurse-submodules https://github.com/LycheeOrg/Lychee.git /app/www && \
curl -o \
/tmp/lychee.tar.gz -L \
"https://github.com/LycheeOrg/Lychee/archive/${LYCHEE_VERSION}.tar.gz" && \
tar xf /tmp/lychee.tar.gz -C \
/app/www --strip-components=1 && \
echo "**** install composer dependencies ****" && \
composer install \
-d /app/www \
@ -69,7 +73,8 @@ RUN \
rm -rf \
/tmp/* \
$HOME/.cache \
$HOME/.composer
$HOME/.composer \
$HOME/.npm
# copy local files
COPY root/ /

8
Jenkinsfile vendored
View File

@ -33,7 +33,7 @@ pipeline {
CI_PORT='80'
CI_SSL='false'
CI_DELAY='120'
CI_DOCKERENV='TZ=US/Pacific'
CI_DOCKERENV='TZ=Europe/London|DB_CONNECTION=sqlite'
CI_AUTH='user:password'
CI_WEBPATH=''
}
@ -460,7 +460,7 @@ pipeline {
--label \"org.opencontainers.image.licenses=GPL-3.0-only\" \
--label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \
--label \"org.opencontainers.image.title=Lychee\" \
--label \"org.opencontainers.image.description=[Lychee](https://lycheeorg.github.io/) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. ### UPGRADE WARNING Please note that the v4 upgrade process resets ALL password-protected albums. Any albums that were made public with a password will need to be re-secured. \" \
--label \"org.opencontainers.image.description=[Lychee](https://lycheeorg.github.io/) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. \" \
--no-cache --pull -t ${IMAGE}:${META_TAG} --platform=linux/amd64 \
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
}
@ -491,7 +491,7 @@ pipeline {
--label \"org.opencontainers.image.licenses=GPL-3.0-only\" \
--label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \
--label \"org.opencontainers.image.title=Lychee\" \
--label \"org.opencontainers.image.description=[Lychee](https://lycheeorg.github.io/) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. ### UPGRADE WARNING Please note that the v4 upgrade process resets ALL password-protected albums. Any albums that were made public with a password will need to be re-secured. \" \
--label \"org.opencontainers.image.description=[Lychee](https://lycheeorg.github.io/) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. \" \
--no-cache --pull -t ${IMAGE}:amd64-${META_TAG} --platform=linux/amd64 \
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
}
@ -519,7 +519,7 @@ pipeline {
--label \"org.opencontainers.image.licenses=GPL-3.0-only\" \
--label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \
--label \"org.opencontainers.image.title=Lychee\" \
--label \"org.opencontainers.image.description=[Lychee](https://lycheeorg.github.io/) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. ### UPGRADE WARNING Please note that the v4 upgrade process resets ALL password-protected albums. Any albums that were made public with a password will need to be re-secured. \" \
--label \"org.opencontainers.image.description=[Lychee](https://lycheeorg.github.io/) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. \" \
--no-cache --pull -f Dockerfile.aarch64 -t ${IMAGE}:arm64v8-${META_TAG} --platform=linux/arm64 \
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"

View File

@ -41,10 +41,6 @@ Find us at:
[Lychee](https://lycheeorg.github.io/) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely."
### UPGRADE WARNING
Please note that the v4 upgrade process resets ALL password-protected albums. Any albums that were made public with a password will need to be re-secured.
[![lychee](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/lychee-icon.png)](https://lycheeorg.github.io/)
## Supported Architectures
@ -63,9 +59,10 @@ The architectures supported by this image are:
## Application Setup
**This image will not work with a prefilled `/pictures` mount, lychee wants total control over this folder**
**This image will not work with a prefilled `/pictures` mount, Lychee wants total control over this folder**
Setup account via the webui, accessible at http://SERVERIP:PORT
Setup mysql/mariadb and account via the webui, accessible at http://SERVERIP:PORT
More info at [lychee](https://lycheeorg.github.io/).
### Customization
@ -81,7 +78,7 @@ post_max_size = 500M
upload_max_filesize = 500M
```
After making these changes, you'll need to restart the Docker container for the changes to take effect. Here's how to do it:
After making these changes, you'll need to restart the Docker container for the changes to take effect.
**Please note that these changes might have implications on your server's performance, depending on its available resources. Thus, it's recommended to modify these settings with caution.**
@ -92,43 +89,31 @@ To help you get started creating a container from this image you can either use
### docker-compose (recommended, [click here for more info](https://docs.linuxserver.io/general/docker-compose))
```yaml
version: "3"
---
version: "2.1"
services:
mariadb:
image: lscr.io/linuxserver/mariadb:latest
container_name: lychee_mariadb
restart: always
volumes:
- /path/to/mariadb/data:/config
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=lychee
- MYSQL_USER=lychee
- MYSQL_PASSWORD=dbpassword
- PGID=1000
- PUID=1000
- TZ=Europe/London
lychee:
image: lscr.io/linuxserver/lychee:latest
container_name: lychee
restart: always
depends_on:
- mariadb
volumes:
- /path/to/config:/config
- /path/to/pictures:/pictures
environment:
- DB_CONNECTION=mysql
- DB_HOST=mariadb
- DB_PORT=3306
- DB_USERNAME=lychee
- DB_PASSWORD=dbpassword
- DB_DATABASE=lychee
- PGID=1000
- PUID=1000
- TZ=Europe/London
- PGID=1000
- TZ=Etc/UTC
- DB_CONNECTION=
- DB_HOST=
- DB_PORT=
- DB_USERNAME=
- DB_PASSWORD=
- DB_DATABASE=
- APP_NAME=Lychee #optional
- APP_URL= #optional
- APP_FORCE_HTTPS= #optional
volumes:
- /path/to/lychee/config:/config
- /path/to/pictures:/pictures
ports:
- 80:80
restart: unless-stopped
```
### docker cli ([click here for more info](https://docs.docker.com/engine/reference/commandline/cli/))
@ -139,14 +124,17 @@ docker run -d \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Etc/UTC \
-e DB_CONNECTION=mysql \
-e DB_HOST=mariadb \
-e DB_PORT=3306 \
-e DB_USERNAME=lychee \
-e DB_PASSWORD=dbpassword \
-e DB_DATABASE=lychee \
-e DB_CONNECTION= \
-e DB_HOST= \
-e DB_PORT= \
-e DB_USERNAME= \
-e DB_PASSWORD= \
-e DB_DATABASE= \
-e APP_NAME=Lychee `#optional` \
-e APP_URL= `#optional` \
-e APP_FORCE_HTTPS= `#optional` \
-p 80:80 \
-v /path/to/config:/config \
-v /path/to/lychee/config:/config \
-v /path/to/pictures:/pictures \
--restart unless-stopped \
lscr.io/linuxserver/lychee:latest
@ -162,14 +150,17 @@ Containers are configured using parameters passed at runtime (such as those abov
| `-e PUID=1000` | for UserID - see below for explanation |
| `-e PGID=1000` | for GroupID - see below for explanation |
| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). |
| `-e DB_CONNECTION=mysql` | for specifying the database type |
| `-e DB_HOST=mariadb` | for specifying the database host |
| `-e DB_PORT=3306` | for specifying the database port |
| `-e DB_USERNAME=lychee` | for specifying the database user |
| `-e DB_PASSWORD=dbpassword` | for specifying the database password |
| `-e DB_DATABASE=lychee` | for specifying the database to be used |
| `-v /config` | Contains all relevant configuration files. |
| `-v /pictures` | Where lychee will store uploaded data. |
| `-e DB_CONNECTION=` | DB type, from `sqlite`, `mysql`, `pqsql`. |
| `-e DB_HOST=` | DB server hostname. For `mysql` and `pgsql` only. |
| `-e DB_PORT=` | DB server port. For `mysql` and `pgsql` only. |
| `-e DB_USERNAME=` | DB user. For `mysql` and `pgsql` only. |
| `-e DB_PASSWORD=` | DB password. For `mysql` and `pgsql` only. |
| `-e DB_DATABASE=` | Path to DB file for `sqlite`. DB name for `mysql` and `pgsql`. |
| `-e APP_NAME=Lychee` | The gallery name. |
| `-e APP_URL=` | The URL you will use to access Lychee including protocol, and port where appropriate. |
| `-e APP_FORCE_HTTPS=` | Set to `true` if running behind an https reverse proxy. |
| `-v /config` | Persistent config files. |
| `-v /pictures` | Where lychee will store uploaded images. |
## Environment variables from files (Docker secrets)
@ -347,6 +338,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
## Versions
* **27.12.23:** - Update image to support v5.
* **25.12.23:** - Existing users should update: site-confs/default.conf - Cleanup default site conf. Build npm dependencies into image.
* **25.05.23:** - Rebase to Alpine 3.18, deprecate armhf.
* **13.04.23:** - Move ssl.conf include to default.conf.

View File

@ -25,6 +25,6 @@ repo_vars:
- CI_PORT='80'
- CI_SSL='false'
- CI_DELAY='120'
- CI_DOCKERENV='TZ=US/Pacific'
- CI_DOCKERENV='TZ=Europe/London|DB_CONNECTION=sqlite'
- CI_AUTH='user:password'
- CI_WEBPATH=''

View File

@ -7,9 +7,6 @@ project_logo: "https://raw.githubusercontent.com/linuxserver/docker-templates/ma
project_blurb: |
[{{ project_name|capitalize }}]({{ project_url }}) is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely."
### UPGRADE WARNING
Please note that the v4 upgrade process resets ALL password-protected albums. Any albums that were made public with a password will need to be re-secured.
project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}"
# supported architectures
@ -22,70 +19,33 @@ common_param_env_vars_enabled: true
param_container_name: "{{ project_name }}"
param_usage_include_vols: true
param_volumes:
- { vol_path: "/config", vol_host_path: "/path/to/config", desc: "Contains all relevant configuration files." }
- { vol_path: "/pictures", vol_host_path: "/path/to/pictures", desc: "Where lychee will store uploaded data." }
- { vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/config", desc: "Persistent config files." }
- { vol_path: "/pictures", vol_host_path: "/path/to/pictures", desc: "Where lychee will store uploaded images." }
param_usage_include_ports: true
param_ports:
- { external_port: "80", internal_port: "80", port_desc: "http gui" }
param_usage_include_env: true
param_env_vars:
- { env_var: "TZ", env_value: "Europe/London", desc: "Specify a timezone to use EG Europe/London"}
- { env_var: "DB_CONNECTION", env_value: "mysql", desc: "for specifying the database type" }
- { env_var: "DB_HOST", env_value: "mariadb", desc: "for specifying the database host" }
- { env_var: "DB_PORT", env_value: "3306", desc: "for specifying the database port" }
- { env_var: "DB_USERNAME", env_value: "lychee", desc: "for specifying the database user" }
- { env_var: "DB_PASSWORD", env_value: "dbpassword", desc: "for specifying the database password" }
- { env_var: "DB_DATABASE", env_value: "lychee", desc: "for specifying the database to be used" }
- { env_var: "DB_CONNECTION", env_value: "", desc: "DB type, from `sqlite`, `mysql`, `pqsql`." }
- { env_var: "DB_HOST", env_value: "", desc: "DB server hostname. For `mysql` and `pgsql` only." }
- { env_var: "DB_PORT", env_value: "", desc: "DB server port. For `mysql` and `pgsql` only." }
- { env_var: "DB_USERNAME", env_value: "", desc: "DB user. For `mysql` and `pgsql` only." }
- { env_var: "DB_PASSWORD", env_value: "", desc: "DB password. For `mysql` and `pgsql` only." }
- { env_var: "DB_DATABASE", env_value: "", desc: "Path to DB file for `sqlite`. DB name for `mysql` and `pgsql`." }
# optional parameters
optional_block_1: false
optional_block_1_items: ""
custom_compose: |
version: "3"
services:
mariadb:
image: lscr.io/linuxserver/mariadb:latest
container_name: lychee_mariadb
restart: always
volumes:
- /path/to/mariadb/data:/config
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=lychee
- MYSQL_USER=lychee
- MYSQL_PASSWORD=dbpassword
- PGID=1000
- PUID=1000
- TZ=Europe/London
lychee:
image: lscr.io/linuxserver/lychee:latest
container_name: lychee
restart: always
depends_on:
- mariadb
volumes:
- /path/to/config:/config
- /path/to/pictures:/pictures
environment:
- DB_CONNECTION=mysql
- DB_HOST=mariadb
- DB_PORT=3306
- DB_USERNAME=lychee
- DB_PASSWORD=dbpassword
- DB_DATABASE=lychee
- PGID=1000
- PUID=1000
- TZ=Europe/London
ports:
- 80:80
opt_param_usage_include_env: true
opt_param_env_vars:
- { env_var: "APP_NAME", env_value: "Lychee", desc: "The gallery name." }
- { env_var: "APP_URL", env_value: "", desc: "The URL you will use to access Lychee including protocol, and port where appropriate." }
- { env_var: "APP_FORCE_HTTPS", env_value: "", desc: "Set to `true` if running behind an https reverse proxy." }
# application setup block
app_setup_block_enabled: true
app_setup_block: |
**This image will not work with a prefilled `/pictures` mount, lychee wants total control over this folder**
**This image will not work with a prefilled `/pictures` mount, Lychee wants total control over this folder**
Setup account via the webui, accessible at http://SERVERIP:PORT
Setup mysql/mariadb and account via the webui, accessible at http://SERVERIP:PORT
More info at [lychee]({{ project_url }}).
### Customization
@ -101,12 +61,13 @@ app_setup_block: |
upload_max_filesize = 500M
```
After making these changes, you'll need to restart the Docker container for the changes to take effect. Here's how to do it:
After making these changes, you'll need to restart the Docker container for the changes to take effect.
**Please note that these changes might have implications on your server's performance, depending on its available resources. Thus, it's recommended to modify these settings with caution.**
# changelog
changelogs:
- { date: "27.12.23:", desc: "Update image to support v5." }
- { date: "25.12.23:", desc: "Existing users should update: site-confs/default.conf - Cleanup default site conf. Build npm dependencies into image." }
- { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." }
- { date: "13.04.23:", desc: "Move ssl.conf include to default.conf." }

View File

@ -1,243 +1,122 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
echo "**** Make sure the uploads (pictures), sym, and logs folders exist ****"
mkdir -p \
/config/{sym,logs} \
/config/sym \
/config/log/lychee \
/pictures
# pre-populate /pictures directory if it's empty
if [ ! "$(ls -A /pictures)" ]; then
if [[ ! "$(ls -A /pictures)" ]]; then
mv /app/www/public/uploads/* /pictures/
lsiown -R abc:abc /pictures
elif [ ! "$(ls -A /pictures/import 2>/dev/null)" ]; then
elif [[ ! "$(ls -A /pictures/import 2>/dev/null)" ]]; then
printf "\n\n\n\nSeems like you tried to use a path thats not managed by lychee, this is unsupported\n\n\n\n"
fi
echo "**** Create the symbolic link for the uploads folder ****"
if [ ! -L /app/www/public/uploads ]; then
cp -nr /app/www/public/uploads/* /pictures
if [[ ! -L /app/www/public/uploads ]]; then
rm -rf /app/www/public/uploads
ln -s /pictures /app/www/public/uploads
fi
echo "**** Create the symbolic link for the sym folder ****"
if [ ! -L /app/www/public/sym ]; then
touch /app/www/public/sym/empty_file
cp -nr /app/www/public/sym/* /config/sym
if [[ ! -L /app/www/public/sym ]]; then
rm -rf /app/www/public/sym
ln -s /config/sym /app/www/public/sym
fi
echo "**** Create the symbolic link for the logs folder ****"
if [ ! -L /app/www/storage/logs ]; then
touch /app/www/storage/logs/empty_file
cp -nr /app/www/storage/logs/* /config/logs
if [[ ! -L /app/www/storage/logs ]]; then
rm -rf /app/www/storage/logs
ln -s /config/logs /app/www/storage/logs
ln -s /config/log/lychee /app/www/storage/logs
fi
echo "**** Create user.ini for php settings ****"
cp -n /defaults/user.ini /config/user.ini
cp -n /defaults/user.ini /config/user.ini 2> >(grep -v 'cp: not replacing')
rm -rf /etc/php82/conf.d/99-user.ini
ln -s /config/user.ini /etc/php82/conf.d/99-user.ini
if [ -z "${DB_CONNECTION}" ]; then
DB_CONNECTION=$(grep "^DB_CONNECTION=" /config/.env 2>/dev/null | cut -d'=' -f2-)
fi
cd /app/www || exit 1
if [ "${DB_CONNECTION}" = "sqlite" ] || [ -z "${DB_CONNECTION}" ]; then
if [ -n "${DB_DATABASE}" ]; then
if [ ! -e "${DB_DATABASE}" ]; then
echo "**** Specified sqlite database doesn't exist. Creating it ****"
echo "**** Please make sure your database is on a persistent volume ****"
if [[ -z "${DB_CONNECTION}" ]]; then
echo "**** No DB_CONNECTION configured, halting init ****"
sleep infinity
elif [[ "${DB_CONNECTION}" = "sqlite" ]]; then
if [[ -n "${DB_DATABASE}" ]]; then
if [[ ! -e "${DB_DATABASE}" ]]; then
touch "${DB_DATABASE}"
lsiown abc:abc "${DB_DATABASE}"
fi
lsiown abc:abc "${DB_DATABASE}"
else
DB_DATABASE="/app/www/database/database.sqlite"
DB_DATABASE="/config/database.sqlite"
export DB_DATABASE
if [ ! -L "${DB_DATABASE}" ]; then
if [ ! -e /config/database.sqlite ]; then
echo "**** Copy the default database to /config ****"
cp "${DB_DATABASE}" /config/database.sqlite
printf "/config/database.sqlite" > /var/run/s6/container_environment/DB_DATABASE
fi
elif [[ "${DB_CONNECTION}" = "mysql" ]]; then
echo "Waiting for DB to be available"
END=$((SECONDS + 30))
while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do
if [[ $(/usr/bin/nc -w1 "${DB_HOST}" "${DB_PORT}" | tr -d '\0') ]]; then
if [[ -n "${RUN}" ]]; then
break
fi
echo "**** Create the symbolic link for the database ****"
rm "${DB_DATABASE}"
ln -s /config/database.sqlite "${DB_DATABASE}"
RUN="RAN"
# we sleep here again due to first run init on DB containers
if [[ ! -f /dbwait.lock ]]; then
sleep 5
fi
else
sleep 1
fi
fi
else
if [ -n "${DB_HOST}" ] && [ -n "${DB_PORT}" ]; then
# check for the mysql endpoint for 30 seconds
until nc -z -v -w30 "${DB_HOST}" "${DB_PORT}"; do
echo "Waiting for database connection..."
sleep 5
done
fi
done
elif [[ "${DB_CONNECTION}" = "pgsql" ]]; then
echo "Waiting for DB to be available"
END=$((SECONDS + 30))
while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do
if pg_isready -h "${DB_HOST}" -p "${DB_PORT}" -q; then
if [[ -n "${RUN}" ]]; then
break
fi
RUN="RAN"
# we sleep here again due to first run init on DB containers
if [[ ! -f /dbwait.lock ]]; then
sleep 5
fi
else
sleep 1
fi
done
fi
echo "**** Copy the .env to /config ****"
if [ ! -e /config/.env ]; then
sed 's|^#DB_DATABASE=$|DB_DATABASE='"${DB_DATABASE}"'|' /app/www/.env.example >/config/.env
if [[ ! -e /config/.env ]]; then
cp -n /app/www/.env.example /config/.env 2> >(grep -v 'cp: not replacing')
fi
if [ ! -L /app/www/.env ]; then
if [[ ! -L /app/www/.env ]]; then
rm -rf /app/www/.env
ln -s /config/.env /app/www/.env
fi
echo "**** Inject .env values ****"
if [ -n "${APP_NAME}" ]; then
sed -i "s|APP_NAME=.*|APP_NAME=${APP_NAME}|i" /config/.env
fi
if [ -n "${APP_ENV}" ]; then
sed -i "s|APP_ENV=.*|APP_ENV=${APP_ENV}|i" /config/.env
fi
if [ -n "${APP_DEBUG}" ]; then
sed -i "s|APP_DEBUG=.*|APP_DEBUG=${APP_DEBUG}|i" /config/.env
fi
if [ -n "${APP_URL}" ]; then
sed -i "s|APP_URL=.*|APP_URL=${APP_URL}|i" /config/.env
fi
if [ -n "${APP_FORCE_HTTPS}" ]; then
sed -i "s|APP_FORCE_HTTPS=.*|APP_FORCE_HTTPS=${APP_FORCE_HTTPS}|i" /config/.env
fi
if [ -n "${DEBUGBAR_ENABLED}" ]; then
sed -i "s|DEBUGBAR_ENABLED=.*|DEBUGBAR_ENABLED=${DEBUGBAR_ENABLED}|i" /config/.env
fi
if [ -n "${DB_OLD_LYCHEE_PREFIX}" ]; then
sed -i "s|DB_OLD_LYCHEE_PREFIX=.*|DB_OLD_LYCHEE_PREFIX=${DB_OLD_LYCHEE_PREFIX}|i" /config/.env
fi
if [ -n "${DB_CONNECTION}" ]; then
sed -i "s|DB_CONNECTION=.*|DB_CONNECTION=${DB_CONNECTION}|i" /config/.env
fi
if [ -n "${DB_HOST}" ]; then
sed -i "s|DB_HOST=.*|DB_HOST=${DB_HOST}|i" /config/.env
fi
if [ -n "${DB_PORT}" ]; then
sed -i "s|DB_PORT=.*|DB_PORT=${DB_PORT}|i" /config/.env
fi
if [ -n "${DB_DATABASE}" ]; then
sed -i "s|DB_DATABASE=.*|DB_DATABASE=${DB_DATABASE}|i" /config/.env
fi
if [ -n "${DB_USERNAME}" ]; then
sed -i "s|DB_USERNAME=.*|DB_USERNAME=${DB_USERNAME}|i" /config/.env
fi
if [ -n "${DB_PASSWORD_FILE}" ]; then
DB_PASSWORD=$(<"${DB_PASSWORD_FILE}")
export DB_PASSWORD
fi
if [ -n "${DB_PASSWORD}" ]; then
sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=${DB_PASSWORD}|i" /config/.env
fi
if [ -z "${TIMEZONE}" ] && [ -n "${TZ}" ]; then
TIMEZONE="${TZ}"
export TIMEZONE
fi
if [ -n "${TIMEZONE}" ]; then
sed -i "s|TIMEZONE=.*|TIMEZONE=${TIMEZONE}|i" /config/.env
fi
if [ -n "${ENABLE_TOKEN_AUTH}" ]; then
sed -i "s|ENABLE_TOKEN_AUTH=.*|ENABLE_TOKEN_AUTH=${ENABLE_TOKEN_AUTH}|i" /config/.env
fi
if [ -n "${CACHE_DRIVER}" ]; then
sed -i "s|CACHE_DRIVER=.*|CACHE_DRIVER=${CACHE_DRIVER}|i" /config/.env
fi
if [ -n "${SESSION_DRIVER}" ]; then
sed -i "s|SESSION_DRIVER=.*|SESSION_DRIVER=${SESSION_DRIVER}|i" /config/.env
fi
if [ -n "${SESSION_LIFETIME}" ]; then
sed -i "s|SESSION_LIFETIME=.*|SESSION_LIFETIME=${SESSION_LIFETIME}|i" /config/.env
fi
if [ -n "${QUEUE_CONNECTION}" ]; then
sed -i "s|QUEUE_DRIVER=.*|QUEUE_DRIVER=${QUEUE_DRIVER}|i" /config/.env
fi
if [ -n "${SECURITY_HEADER_HSTS_ENABLE}" ]; then
sed -i "s|SECURITY_HEADER_HSTS_ENABLE=.*|SECURITY_HEADER_HSTS_ENABLE=${SECURITY_HEADER_HSTS_ENABLE}|i" /config/.env
fi
if [ -n "${SESSION_SECURE_COOKIE}" ]; then
sed -i "s|SESSION_SECURE_COOKIE=.*|SESSION_SECURE_COOKIE=${SESSION_SECURE_COOKIE}|i" /config/.env
fi
if [ -n "${REDIS_SCHEME}" ]; then
sed -i "s|REDIS_SCHEME=.*|REDIS_SCHEME=${REDIS_SCHEME}|i" /config/.env
fi
if [ -n "${REDIS_PATH}" ]; then
sed -i "s|REDIS_PATH=.*|REDIS_PATH=${REDIS_PATH}|i" /config/.env
fi
if [ -n "${REDIS_HOST}" ]; then
sed -i "s|REDIS_HOST=.*|REDIS_HOST=${REDIS_HOST}|i" /config/.env
fi
if [ -n "${REDIS_PORT}" ]; then
sed -i "s|REDIS_PORT=.*|REDIS_PORT=${REDIS_PORT}|i" /config/.env
fi
if [ -n "${REDIS_PASSWORD_FILE}" ]; then
REDIS_PASSWORD=$(<"${REDIS_PASSWORD_FILE}")
export REDIS_PASSWORD
fi
if [ -n "${REDIS_PASSWORD}" ]; then
sed -i "s|REDIS_PASSWORD=.*|REDIS_PASSWORD=${REDIS_PASSWORD}|i" /config/.env
fi
if [ -n "${MAIL_DRIVER}" ]; then
sed -i "s|MAIL_DRIVER=.*|MAIL_DRIVER=${MAIL_DRIVER}|i" /config/.env
fi
if [ -n "${MAIL_HOST}" ]; then
sed -i "s|MAIL_HOST=.*|MAIL_HOST=${MAIL_HOST}|i" /config/.env
fi
if [ -n "${MAIL_PORT}" ]; then
sed -i "s|MAIL_PORT=.*|MAIL_PORT=${MAIL_PORT}|i" /config/.env
fi
if [ -n "${MAIL_USERNAME}" ]; then
sed -i "s|MAIL_USERNAME=.*|MAIL_USERNAME=${MAIL_USERNAME}|i" /config/.env
fi
if [ -n "${MAIL_PASSWORD_FILE}" ]; then
MAIL_PASSWORD=$(<"${MAIL_PASSWORD_FILE}")
export MAIL_PASSWORD
fi
if [ -n "${MAIL_PASSWORD}" ]; then
sed -i "s|MAIL_PASSWORD=.*|MAIL_PASSWORD=${MAIL_PASSWORD}|i" /config/.env
fi
if [ -n "${MAIL_ENCRYPTION}" ]; then
sed -i "s|MAIL_ENCRYPTION=.*|MAIL_ENCRYPTION=${MAIL_ENCRYPTION}|i" /config/.env
fi
if [ -n "${MAIL_FROM_NAME}" ]; then
sed -i "s|MAIL_FROM_NAME=.*|MAIL_FROM_NAME=${MAIL_FROM_NAME}|i" /config/.env
fi
if [ -n "${MAIL_FROM_ADDRESS}" ]; then
sed -i "s|MAIL_FROM_ADDRESS=.*|MAIL_FROM_ADDRESS=${MAIL_FROM_ADDRESS}|i" /config/.env
fi
if [ -n "${TRUSTED_PROXIES}" ]; then
sed -i "s|TRUSTED_PROXIES=.*|TRUSTED_PROXIES=${TRUSTED_PROXIES}|i" /config/.env
if grep -qPe '^APP_KEY=$' /config/.env; then
echo "**** Generating app key ****"
php /app/www/artisan key:generate -n
fi
if [ ! -e /tmp/first_run ]; then
echo "**** Generate the key (to make sure that cookies cannot be decrypted etc) ****"
php artisan key:generate -n
echo "**** Migrate the database ****"
php artisan migrate --force
touch /tmp/first_run
fi
php /app/www/artisan migrate --force
echo "**** Make sure user.css exists and symlink it ****"
touch -a /config/user.css
if [ ! -L /app/www/public/dist/user.css ]; then
if [[ ! -L /app/www/public/dist/user.css ]]; then
rm /app/www/public/dist/user.css
ln -s /config/user.css /app/www/public/dist/user.css
fi
echo "**** Make sure custom.js exists and symlink it ****"
touch -a /config/custom.js
if [ ! -L /app/www/public/dist/custom.js ]; then
if [[ ! -L /app/www/public/dist/custom.js ]]; then
rm /app/www/public/dist/custom.js
ln -s /config/custom.js /app/www/public/dist/custom.js
fi
echo "**** Make sure Laravel's log exists ****"
touch /config/logs/laravel.log
echo "**** Set Permissions ****"
# permissions
lsiown -R abc:abc \
/app/www \
/app/www/storage \
/config
# set lockfile to avoid DB waits for this specific container
touch /dbwait.lock