mirror of
https://github.com/linuxserver/docker-lychee.git
synced 2026-02-05 10:59:42 +08:00
upgrade for lychee v4 with an upgrade path from v3 to v4
This commit is contained in:
parent
2717717b79
commit
b65d578bbe
62
Dockerfile
62
Dockerfile
@ -1,56 +1,58 @@
|
||||
FROM lsiobase/nginx:3.11
|
||||
FROM lsiobase/nginx:3.10
|
||||
|
||||
# set version label
|
||||
ARG BUILD_DATE
|
||||
ARG VERSION
|
||||
ARG LYCHEE_RELEASE
|
||||
ARG LYCHEE_VERSION
|
||||
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||
LABEL maintainer="chbmb"
|
||||
|
||||
RUN \
|
||||
echo "**** install packages ****" && \
|
||||
echo "**** install build packages ****" && \
|
||||
apk add --no-cache --virtual=build-dependencies \
|
||||
git \
|
||||
composer && \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
imagemagick \
|
||||
jq \
|
||||
mc \
|
||||
ffmpeg \
|
||||
php7-curl \
|
||||
php7-dom \
|
||||
php7-exif \
|
||||
php7-gd \
|
||||
php7-imagick \
|
||||
php7-json \
|
||||
php7-mbstring \
|
||||
php7-mysqli \
|
||||
php7-mysqlnd \
|
||||
php7-phar \
|
||||
php7-zip \
|
||||
re2c && \
|
||||
php7-pdo_mysql \
|
||||
php7-session \
|
||||
php7-tokenizer \
|
||||
php7-xml \
|
||||
php7-zip && \
|
||||
echo "**** install lychee ****" && \
|
||||
if [ -z ${LYCHEE_RELEASE+x} ]; then \
|
||||
LYCHEE_RELEASE=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/releases/latest" \
|
||||
mkdir -p /app/lychee && \
|
||||
if [ -z ${LYCHEE_VERSION} ]; then \
|
||||
LYCHEE_VERSION=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/releases/latest" \
|
||||
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
|
||||
fi && \
|
||||
LYCHEE_FILENAME=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/releases/latest" \
|
||||
| jq -jr '. | .assets[0].name') && \
|
||||
mkdir -p \
|
||||
/usr/share/webapps/lychee && \
|
||||
curl -o \
|
||||
/tmp/lychee.zip -L \
|
||||
"https://github.com/LycheeOrg/Lychee/releases/download/${LYCHEE_RELEASE}/${LYCHEE_FILENAME}" && \
|
||||
unzip /tmp/lychee.zip -d /tmp && \
|
||||
cp -R /tmp/Lychee*/. /usr/share/webapps/lychee/ && \
|
||||
echo "**** install composer ****" && \
|
||||
cd /tmp && \
|
||||
curl -sS https://getcomposer.org/installer | php && \
|
||||
mv /tmp/composer.phar /usr/local/bin/composer && \
|
||||
/tmp/lychee.tar.gz -L \
|
||||
"https://github.com/LycheeOrg/Lychee/archive/${LYCHEE_VERSION}.tar.gz" && \
|
||||
tar xf \
|
||||
/tmp/lychee.tar.gz -C \
|
||||
/app/lychee/ --strip-components=1 && \
|
||||
cd /app/lychee && \
|
||||
echo "**** install composer dependencies ****" && \
|
||||
composer install -d /usr/share/webapps/lychee && \
|
||||
composer install \
|
||||
-d /app/lychee \
|
||||
--no-dev \
|
||||
--no-suggest \
|
||||
--no-interaction && \
|
||||
echo "**** cleanup ****" && \
|
||||
apk del --purge \
|
||||
build-dependencies && \
|
||||
rm -rf \
|
||||
/root/.cache \
|
||||
/tmp/*
|
||||
|
||||
# add local files
|
||||
COPY root/ /
|
||||
|
||||
# ports and volumes
|
||||
EXPOSE 80
|
||||
VOLUME /config /pictures
|
||||
|
||||
@ -3,54 +3,49 @@ FROM lsiobase/nginx:arm64v8-3.11
|
||||
# set version label
|
||||
ARG BUILD_DATE
|
||||
ARG VERSION
|
||||
ARG LYCHEE_RELEASE
|
||||
ARG LYCHEE_VERSION
|
||||
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||
LABEL maintainer="chbmb"
|
||||
|
||||
RUN \
|
||||
echo "**** install packages ****" && \
|
||||
echo "**** install build packages ****" && \
|
||||
apk add --no-cache --virtual=build-dependencies \
|
||||
git \
|
||||
composer && \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
imagemagick \
|
||||
jq \
|
||||
mc \
|
||||
ffmpeg \
|
||||
php7-curl \
|
||||
php7-exif \
|
||||
php7-gd \
|
||||
php7-imagick \
|
||||
php7-json \
|
||||
php7-mbstring \
|
||||
php7-mysqli \
|
||||
php7-mysqlnd \
|
||||
php7-phar \
|
||||
php7-zip \
|
||||
re2c && \
|
||||
php7-pdo_mysql \
|
||||
php7-session \
|
||||
php7-tokenizer \
|
||||
php7-xml \
|
||||
php7-zip && \
|
||||
echo "**** install lychee ****" && \
|
||||
if [ -z ${LYCHEE_RELEASE+x} ]; then \
|
||||
LYCHEE_RELEASE=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/releases/latest" \
|
||||
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
|
||||
LYCHEE_RELEASE=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/commits/master" \
|
||||
| awk '/sha/{print $4;exit}' FS='[""]'); \
|
||||
fi && \
|
||||
LYCHEE_FILENAME=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/releases/latest" \
|
||||
| jq -jr '. | .assets[0].name') && \
|
||||
mkdir -p \
|
||||
/usr/share/webapps/lychee && \
|
||||
curl -o \
|
||||
/tmp/lychee.zip -L \
|
||||
"https://github.com/LycheeOrg/Lychee/releases/download/${LYCHEE_RELEASE}/${LYCHEE_FILENAME}" && \
|
||||
unzip /tmp/lychee.zip -d /tmp && \
|
||||
cp -R /tmp/Lychee*/. /usr/share/webapps/lychee/ && \
|
||||
echo "**** install composer ****" && \
|
||||
cd /tmp && \
|
||||
curl -sS https://getcomposer.org/installer | php && \
|
||||
mv /tmp/composer.phar /usr/local/bin/composer && \
|
||||
git clone --recursive https://github.com/LycheeOrg/Lychee /app/lychee && \
|
||||
git -C /app/lychee checkout ${LYCHEE_RELEASE} && \
|
||||
echo "**** install composer dependencies ****" && \
|
||||
composer install -d /usr/share/webapps/lychee && \
|
||||
composer install \
|
||||
-d /app/lychee \
|
||||
--no-dev \
|
||||
--no-suggest \
|
||||
--no-interaction && \
|
||||
echo "**** cleanup ****" && \
|
||||
apk del --purge \
|
||||
build-dependencies && \
|
||||
rm -rf \
|
||||
/root/.cache \
|
||||
/tmp/*
|
||||
|
||||
# add local files
|
||||
COPY root/ /
|
||||
|
||||
# ports and volumes
|
||||
EXPOSE 80
|
||||
VOLUME /config /pictures
|
||||
|
||||
@ -3,54 +3,49 @@ FROM lsiobase/nginx:arm32v7-3.11
|
||||
# set version label
|
||||
ARG BUILD_DATE
|
||||
ARG VERSION
|
||||
ARG LYCHEE_RELEASE
|
||||
ARG LYCHEE_VERSION
|
||||
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
|
||||
LABEL maintainer="chbmb"
|
||||
|
||||
RUN \
|
||||
echo "**** install packages ****" && \
|
||||
echo "**** install build packages ****" && \
|
||||
apk add --no-cache --virtual=build-dependencies \
|
||||
git \
|
||||
composer && \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
imagemagick \
|
||||
jq \
|
||||
mc \
|
||||
ffmpeg \
|
||||
php7-curl \
|
||||
php7-exif \
|
||||
php7-gd \
|
||||
php7-imagick \
|
||||
php7-json \
|
||||
php7-mbstring \
|
||||
php7-mysqli \
|
||||
php7-mysqlnd \
|
||||
php7-phar \
|
||||
php7-zip \
|
||||
re2c && \
|
||||
php7-pdo_mysql \
|
||||
php7-session \
|
||||
php7-tokenizer \
|
||||
php7-xml \
|
||||
php7-zip && \
|
||||
echo "**** install lychee ****" && \
|
||||
if [ -z ${LYCHEE_RELEASE+x} ]; then \
|
||||
LYCHEE_RELEASE=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/releases/latest" \
|
||||
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
|
||||
LYCHEE_RELEASE=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/commits/master" \
|
||||
| awk '/sha/{print $4;exit}' FS='[""]'); \
|
||||
fi && \
|
||||
LYCHEE_FILENAME=$(curl -sX GET "https://api.github.com/repos/LycheeOrg/Lychee/releases/latest" \
|
||||
| jq -jr '. | .assets[0].name') && \
|
||||
mkdir -p \
|
||||
/usr/share/webapps/lychee && \
|
||||
curl -o \
|
||||
/tmp/lychee.zip -L \
|
||||
"https://github.com/LycheeOrg/Lychee/releases/download/${LYCHEE_RELEASE}/${LYCHEE_FILENAME}" && \
|
||||
unzip /tmp/lychee.zip -d /tmp && \
|
||||
cp -R /tmp/Lychee*/. /usr/share/webapps/lychee/ && \
|
||||
echo "**** install composer ****" && \
|
||||
cd /tmp && \
|
||||
curl -sS https://getcomposer.org/installer | php && \
|
||||
mv /tmp/composer.phar /usr/local/bin/composer && \
|
||||
git clone --recursive https://github.com/LycheeOrg/Lychee /app/lychee && \
|
||||
git -C /app/lychee checkout ${LYCHEE_RELEASE} && \
|
||||
echo "**** install composer dependencies ****" && \
|
||||
composer install -d /usr/share/webapps/lychee && \
|
||||
composer install \
|
||||
-d /app/lychee \
|
||||
--no-dev \
|
||||
--no-suggest \
|
||||
--no-interaction && \
|
||||
echo "**** cleanup ****" && \
|
||||
apk del --purge \
|
||||
build-dependencies && \
|
||||
rm -rf \
|
||||
/root/.cache \
|
||||
/tmp/*
|
||||
|
||||
# add local files
|
||||
COPY root/ /
|
||||
|
||||
# ports and volumes
|
||||
EXPOSE 80
|
||||
VOLUME /config /pictures
|
||||
|
||||
@ -25,7 +25,10 @@ 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_HOST", env_value: "<yourdbhost>", desc: "for specifying the database host" }
|
||||
- { env_var: "DB_USERNAME", env_value: "<yourdbuser>", desc: "for specifying the database user" }
|
||||
- { env_var: "DB_PASSWORD", env_value: "<yourdbpass>", desc: "for specifying the database password" }
|
||||
- { env_var: "DB_DATABASE", env_value: "monica", desc: "for specifying the database to be used" }
|
||||
|
||||
# optional parameters
|
||||
optional_block_1: false
|
||||
@ -34,10 +37,11 @@ optional_block_1_items: ""
|
||||
# application setup block
|
||||
app_setup_block_enabled: true
|
||||
app_setup_block: |
|
||||
Setup mysql/mariadb and account via the webui, accessible at http://SERVERIP:PORT
|
||||
More info at [lychee]({{ project_url }}).
|
||||
Setup mysql/mariadb and account via the webui, accessible at http://SERVERIP:PORT
|
||||
More info at [lychee]({{ project_url }}).
|
||||
# changelog
|
||||
changelogs:
|
||||
- { date: "01.05.20:", desc: "Upgrade to Lychee v4" }
|
||||
- { date: "19.12.19:", desc: "Rebasing to alpine 3.11." }
|
||||
- { date: "23.10.19:", desc: "Increase fastcgi timeouts (existing users need to manually update)." }
|
||||
- { date: "19.09.19:", desc: "Update project website url." }
|
||||
|
||||
@ -1,28 +1,49 @@
|
||||
## Version 2020/05/01 - Changelog: https://github.com/linuxserver/docker-lychee/commits/master/root/defaults/default
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
root /var/www/localhost/lychee;
|
||||
index index.html index.htm index.php;
|
||||
listen 80 default_server;
|
||||
|
||||
server_name _;
|
||||
client_max_body_size 0;
|
||||
listen 443 ssl;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html /index.php?$args =404;
|
||||
}
|
||||
root /app/lychee/public;
|
||||
index index.php index.html index.htm;
|
||||
|
||||
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
|
||||
expires max;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
|
||||
server_name _;
|
||||
|
||||
ssl_certificate /config/keys/cert.crt;
|
||||
ssl_certificate_key /config/keys/cert.key;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
error_page 599 = @noauth;
|
||||
|
||||
location / {
|
||||
if (!-f /config/nginx/.htpasswd) {
|
||||
return 599;
|
||||
}
|
||||
auth_basic "Restricted";
|
||||
auth_basic_user_file /config/nginx/.htpasswd;
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_read_timeout 1800;
|
||||
fastcgi_send_timeout 1800;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
location @noauth {
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
|
||||
if (!-e $request_filename)
|
||||
{
|
||||
rewrite ^/(.*)$ /index.php?/$1 last;
|
||||
break;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
# With php5-cgi alone:
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
# With php5-fpm:
|
||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
}
|
||||
}
|
||||
|
||||
30
root/defaults/upgrade.php
Normal file
30
root/defaults/upgrade.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
logMessage("Attempting to upgrade v3 config to v4...");
|
||||
|
||||
if (!file_exists("/config/lychee/config.php")) {
|
||||
logMessage("No v3 config found at /config/lychee/config.php. Exiting.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once "/config/lychee/config.php";
|
||||
|
||||
logMessage("Found v3 config with the following variables:");
|
||||
logMessage(" dbHost = $dbHost");
|
||||
logMessage(" dbUser = $dbUser");
|
||||
logMessage(" dbPassword = $dbPassword");
|
||||
logMessage(" dbName = $dbName");
|
||||
logMessage(" dbTablePrefix = $dbTablePrefix");
|
||||
|
||||
`sed -i "s|DB_HOST=.*$|DB_HOST=$dbHost|g" /config/.env`;
|
||||
`sed -i "s|DB_USERNAME=.*$|DB_USERNAME=$dbUser|g" /config/.env`;
|
||||
`sed -i "s|DB_PASSWORD=.*$|DB_PASSWORD=$dbPassword|g" /config/.env`;
|
||||
`sed -i "s|DB_DATABASE=.*$|DB_DATABASE=$dbName|g" /config/.env`;
|
||||
`sed -i "s|DB_OLD_LYCHEE_PREFIX=.*$|DB_OLD_LYCHEE_PREFIX=$dbTablePrefix|g" /config/.env`;
|
||||
|
||||
logMessage("Upgrade complete.");
|
||||
|
||||
function logMessage($msg)
|
||||
{
|
||||
echo "$msg\n";
|
||||
}
|
||||
@ -1,42 +1,75 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# create our folders
|
||||
mkdir -p \
|
||||
/config/lychee
|
||||
DB_HOST=${DB_HOST:-mariadb}
|
||||
DB_USERNAME=${DB_USERNAME:-root}
|
||||
DB_PASSWORD=${DB_PASSWORD:-root}
|
||||
DB_DATABASE=${DB_DATABASE:-lychee}
|
||||
|
||||
for image_index in {big,import,medium,small,thumb}; do
|
||||
if [ ! -f /pictures/${image_index}/index.html ]; then
|
||||
mkdir -p /pictures/${image_index}
|
||||
: > /pictures/${image_index}/index.html
|
||||
# copy config
|
||||
[[ ! -e /config/user.ini ]] && \
|
||||
cp /defaults/user.ini /config/user.ini
|
||||
cp /config/user.ini /etc/php7/conf.d/99-user.ini
|
||||
|
||||
# check for .env and copy default if needed
|
||||
if [ ! -f "/config/.env" ]; then
|
||||
cp /app/lychee/.env.example /config/.env
|
||||
|
||||
# attempt upgrade
|
||||
if [ -f "/config/lychee/config.php" ]; then
|
||||
php /defaults/upgrade.php
|
||||
mv /config/lychee /config/lychee.old
|
||||
|
||||
# force nginx config upgrade
|
||||
mv /config/nginx/site-confs/default /config/nginx/default.bak
|
||||
mv /defaults/default /config/nginx/site-confs/default
|
||||
else
|
||||
# build initial .env from variables
|
||||
sed -i "s|DB_HOST=.*$|DB_HOST=${DB_HOST}|g" /config/.env
|
||||
sed -i "s|DB_USERNAME=.*$|DB_USERNAME=${DB_USERNAME}|g" /config/.env
|
||||
sed -i "s|DB_PASSWORD=.*$|DB_PASSWORD=${DB_PASSWORD}|g" /config/.env
|
||||
sed -i "s|DB_DATABASE=.*$|DB_DATABASE=${DB_DATABASE}|g" /config/.env
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# copy config
|
||||
[[ ! -e /config/lychee/user.ini ]] && \
|
||||
cp /defaults/user.ini /config/lychee/user.ini
|
||||
cp /config/lychee/user.ini /usr/share/webapps/lychee/.user.ini
|
||||
ln -sf /config/.env /app/lychee/.env
|
||||
|
||||
# create symlinks
|
||||
[[ ! -L /var/www/localhost/lychee ]] && \
|
||||
ln -s /usr/share/webapps/lychee /var/www/localhost/lychee
|
||||
[[ -d /usr/share/webapps/lychee/uploads ]] && \
|
||||
rm -rf /usr/share/webapps/lychee/uploads
|
||||
[[ ! -L /usr/share/webapps/lychee/uploads ]] && \
|
||||
ln -s /pictures /usr/share/webapps/lychee/uploads
|
||||
[[ -d /usr/share/webapps/lychee/data ]] && \
|
||||
rm -rf /usr/share/webapps/lychee/data
|
||||
[[ ! -L /usr/share/webapps/lychee/data ]]
|
||||
ln -s /config/lychee /usr/share/webapps/lychee/data
|
||||
# pre-populate /pictures directory if it's empty
|
||||
if [ ! "$(ls -A /pictures)" ]; then
|
||||
mv /app/lychee/public/uploads/* /pictures/
|
||||
fi
|
||||
|
||||
# set ffmpeg binary path
|
||||
sed -i 's#$ffmpeg = FFMpeg\\FFMpeg::create();#$ffmpeg = FFMpeg\\FFMpeg::create(array('"'"'ffmpeg.binaries'"'"' => '"'"'/usr/bin/ffmpeg'"'"','"'"'ffprobe.binaries'"'"' => '"'"'/usr/bin/ffprobe'"'"',));#g' \
|
||||
/usr/share/webapps/lychee/php/Modules/Photo.php
|
||||
sed -i 's#$ffprobe = FFMpeg\\FFProbe::create();#$ffprobe = FFMpeg\\FFProbe::create(array('"'"'ffmpeg.binaries'"'"' => '"'"'/usr/bin/ffmpeg'"'"','"'"'ffprobe.binaries'"'"' => '"'"'/usr/bin/ffprobe'"'"',));#g' \
|
||||
/usr/share/webapps/lychee/php/Modules/Photo.php
|
||||
[[ ! -L "/app/lychee/public/uploads" ]] && rm -rf /app/lychee/public/uploads
|
||||
ln -sf /pictures /app/lychee/public/uploads
|
||||
|
||||
# Create API key if needed
|
||||
if [ ! -f "/config/LYCHEE_APP_KEY.txt" ];
|
||||
then
|
||||
echo "Generating Lychee app key for first run"
|
||||
key=$(php /app/lychee/artisan key:generate --show)
|
||||
echo $key > /config/LYCHEE_APP_KEY.txt
|
||||
echo "App Key set to $key you can modify the file to update /config/LYCHEE_APP_KEY.txt"
|
||||
elif [ -f "/config/LYCHEE_APP_KEY.txt" ];
|
||||
then
|
||||
echo "App Key found - setting variable for seds"
|
||||
key=$(cat /config/LYCHEE_APP_KEY.txt)
|
||||
fi
|
||||
|
||||
# set app key here
|
||||
sed -i "s|APP_KEY=$|APP_KEY=${key}|g" /config/.env
|
||||
|
||||
# handle storage directory
|
||||
[[ ! -e "/config/storage" ]] && \
|
||||
mv /app/lychee/storage /config/
|
||||
|
||||
rm -rf /app/lychee/storage
|
||||
ln -s /config/storage /app/lychee/storage
|
||||
|
||||
# update database - will set up database if fresh or migrate existing - only run if ENV variables are set (so not on first launch)
|
||||
echo "attempt running database migrations"
|
||||
php /app/lychee/artisan migrate
|
||||
|
||||
# permissions
|
||||
chown -R abc:abc \
|
||||
/app/lychee \
|
||||
/config \
|
||||
/pictures \
|
||||
/usr/share/webapps/lychee \
|
||||
/var/www/localhost/lychee
|
||||
/pictures
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user