diff --git a/Dockerfile b/Dockerfile index 9dbc53e..503b847 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN \ exiftool \ ffmpeg \ gd \ + grep \ imagemagick \ jpegoptim \ php82-bcmath \ @@ -26,13 +27,11 @@ 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 && \ echo "**** configure php-fpm to pass env vars ****" && \ @@ -44,7 +43,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 \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index ca19e4a..0f1cf39 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -19,6 +19,7 @@ RUN \ exiftool \ ffmpeg \ gd \ + grep \ imagemagick \ jpegoptim \ php82-bcmath \ diff --git a/readme-vars.yml b/readme-vars.yml index 7c62f0f..e1d02c2 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -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: "sqlite", 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." } diff --git a/root/etc/s6-overlay/s6-rc.d/init-lychee-config/run b/root/etc/s6-overlay/s6-rc.d/init-lychee-config/run index 6fcd0a1..8580f49 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-lychee-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-lychee-config/run @@ -1,9 +1,8 @@ #!/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,log} \ /pictures # pre-populate /pictures directory if it's empty @@ -14,230 +13,112 @@ 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 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 + cp -nr /app/www/public/sym/* /config/sym 2> >(grep -v 'cp: not replacing') 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 rm -rf /app/www/storage/logs - ln -s /config/logs /app/www/storage/logs + ln -s /config/log /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 ****" 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 + fi +elif [ "${DB_CONNECTION}" = "mysql" ]; then + if [[ -z "${DB_PORT}" ]]; then + DB_PORT="3306" + fi + 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 + done +elif [ "${DB_CONNECTION}" = "pgsql" ]; then + if [[ -z "${DB_PORT}" ]]; then + DB_PORT="5432" 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 + 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 + 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 + cp -n /app/www/.env.example /config/.env 2> >(grep -v 'cp: not replacing') fi 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 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 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