Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparing docker image for v6 #208

Merged
merged 10 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ RUN \
rm storage/framework/views/* 2> /dev/null || true && \
rm storage/logs/* 2> /dev/null || true && \
chown -R www-data:www-data /var/www/html/Lychee && \
chmod -R g+ws storage/image-jobs storage/livewire-tmp && \
chmod -R g+ws storage/image-jobs && \
chmod -R g+ws storage/livewire-tmp || true && \
chmod -R g+ws storage/image-tmp || true && \
chmod -R g+ws storage/extract-jobs || true && \
echo "* * * * * www-data cd /var/www/html/Lychee && php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab && \
apt-get purge -y --autoremove git composer && \
apt-get clean -qy &&\
Expand Down Expand Up @@ -102,7 +105,7 @@ COPY --from=static_builder --chown=www-data:www-data /app/public /var/www/html/L
COPY default.conf /etc/nginx/nginx.conf

EXPOSE 80
VOLUME /conf /uploads /sym /logs
VOLUME /conf /uploads /sym /logs /image-tmp /image-jobs /extract-jobs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels excessive as they should all be temporary, but 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They probably need permissions checks too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point on permission checks.

yeah I know it feels excessive, but that way you may run your docker base container on a small instance and have some scratch pad for the tmp files. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed fe34506

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I know it feels excessive, but that way you may run your docker base container on a small instance and have some scratch pad for the tmp files. :)

But do you need three separate ones? e.g. it could be /lychee-tmp/image-tmp etc? That would also save remapping if we add more or rename them again.

It's good enough to merge, just feels a bit much.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But do you need three separate ones? e.g. it could be /lychee-tmp/image-tmp etc? That would also save remapping if we add more or rename them again.

It's good enough to merge, just feels a bit much.

Ohhh, good point, I like it!
I will fix that in v6.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just cheat it here, but if there's a good place in the v6 too, sure :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


WORKDIR /var/www/html/Lychee

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ services:
#- APP_URL=http://localhost
#- APP_DIR=
#- DEBUGBAR_ENABLEd=false
#- VUEJS_ENABLED=true
#- LEGACY_API_ENABLED=false
#- LEGACY_V4_REDIRECT=false
#- DB_OLD_LYCHEE_PREFIX=''
- DB_CONNECTION=mysql
Expand Down
40 changes: 32 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ fi


echo "**** Make sure the /conf /uploads /sym /logs folders exist ****"
[ ! -d /conf ] && mkdir -p /conf
[ ! -d /uploads ] && mkdir -p /uploads
[ ! -d /sym ] && mkdir -p /sym
[ ! -d /logs ] && mkdir -p /logs
[ ! -d /conf ] && mkdir -p /conf
[ ! -d /uploads ] && mkdir -p /uploads
[ ! -d /sym ] && mkdir -p /sym
[ ! -d /logs ] && mkdir -p /logs
[ ! -d /image-tmp ] && mkdir -p /image-tmp
[ ! -d /image-jobs ] && mkdir -p /image-jobs
[ ! -d /extract-jobs ] && mkdir -p /extract-jobs

echo "**** Create the symbolic link for the /uploads folder ****"
[ ! -L /var/www/html/Lychee/public/uploads ] && \
Expand All @@ -58,6 +61,27 @@ echo "**** Create the symbolic link for the /logs folder ****"
rm -r /var/www/html/Lychee/storage/logs && \
ln -s /logs /var/www/html/Lychee/storage/logs

echo "**** Create the symbolic link for the /image-tmp folder ****"
[ ! -L /var/www/html/Lychee/storage/image-tmp ] && \
touch /var/www/html/Lychee/storage/image-tmp/empty_file && \
cp -r /var/www/html/Lychee/storage/image-tmp/* /image-tmp && \
rm -r /var/www/html/Lychee/storage/image-tmp && \
ln -s /image-tmp /var/www/html/Lychee/storage/image-tmp

echo "**** Create the symbolic link for the /image-jobs folder ****"
[ ! -L /var/www/html/Lychee/storage/image-jobs ] && \
touch /var/www/html/Lychee/storage/image-jobs/empty_file && \
cp -r /var/www/html/Lychee/storage/image-jobs/* /image-jobs && \
rm -r /var/www/html/Lychee/storage/image-jobs && \
ln -s /image-jobs /var/www/html/Lychee/storage/image-jobs

echo "**** Create the symbolic link for the /extract-jobs folder ****"
[ ! -L /var/www/html/Lychee/storage/extract-jobs ] && \
touch /var/www/html/Lychee/storage/extract-jobs/empty_file && \
cp -r /var/www/html/Lychee/storage/extract-jobs/* /extract-jobs && \
rm -r /var/www/html/Lychee/storage/extract-jobs && \
ln -s /extract-jobs /var/www/html/Lychee/storage/extract-jobs

cd /var/www/html/Lychee

if [ "$DB_CONNECTION" = "sqlite" ] || [ -z "$DB_CONNECTION" ]
Expand Down Expand Up @@ -142,12 +166,12 @@ if [ -n "$SKIP_PERMISSIONS_CHECKS" ] && [ "${SKIP_PERMISSIONS_CHECKS,,}" = "yes"
else
echo "**** Set Permissions ****"
# Set ownership of directories, then files and only when required. See LycheeOrg/Lychee-Docker#120
find /sym /uploads /logs -type d \( ! -user "$USER" -o ! -group "$USER" \) -exec chown -R "$USER":"$USER" \{\} \;
find /conf/.env /sym /uploads /logs \( ! -user "$USER" -o ! -group "$USER" \) -exec chown "$USER":"$USER" \{\} \;
find /sym /uploads /logs /image-tmp /image-jobs /extract-jobs -type d \( ! -user "$USER" -o ! -group "$USER" \) -exec chown -R "$USER":"$USER" \{\} \;
find /conf/.env /sym /uploads /logs /image-tmp /image-jobs /extract-jobs \( ! -user "$USER" -o ! -group "$USER" \) -exec chown "$USER":"$USER" \{\} \;
# Laravel needs to be able to chmod user.css and custom.js for no good reason
find /conf/user.css /conf/custom.js /logs/laravel.log \( ! -user "www-data" -o ! -group "$USER" \) -exec chown www-data:"$USER" \{\} \;
find /sym /uploads /logs -type d \( ! -perm -ug+w -o ! -perm -ugo+rX -o ! -perm -g+s \) -exec chmod -R ug+w,ugo+rX,g+s \{\} \;
find /conf/user.css /conf/custom.js /conf/.env /sym /uploads /logs \( ! -perm -ug+w -o ! -perm -ugo+rX \) -exec chmod ug+w,ugo+rX \{\} \;
find /sym /uploads /logs /image-tmp /image-jobs /extract-jobs -type d \( ! -perm -ug+w -o ! -perm -ugo+rX -o ! -perm -g+s \) -exec chmod -R ug+w,ugo+rX,g+s \{\} \;
find /conf/user.css /conf/custom.js /conf/.env /sym /uploads /logs /image-tmp /image-jobs /extract-jobs \( ! -perm -ug+w -o ! -perm -ugo+rX \) -exec chmod ug+w,ugo+rX \{\} \;
fi

# Update CA Certificates if we're using armv7 because armv7 is weird (#76)
Expand Down
6 changes: 6 additions & 0 deletions inject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ if [ "$DEBUGBAR_ENABLED" != '' ]; then
if [ "$LIVEWIRE_ENABLED" != '' ]; then
replace_or_insert "LIVEWIRE_ENABLED" "$LIVEWIRE_ENABLED"
fi
if [ "$VUEJS_ENABLED" != '' ]; then
replace_or_insert "VUEJS_ENABLED" "$VUEJS_ENABLED"
fi
if [ "$LEGACY_API_ENABLED" != '' ]; then
replace_or_insert "LEGACY_API_ENABLED" "$LEGACY_API_ENABLED"
fi
if [ "$LOG_VIEWER_ENABLED" != '' ]; then
replace_or_insert "LOG_VIEWER_ENABLED" "$LOG_VIEWER_ENABLED"
fi
Expand Down
Loading