mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
Merge pull request #3101 from tooboredtocode/develop
improve docker run speed
This commit is contained in:
@@ -6,6 +6,8 @@ RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg li
|
||||
#Print all logs without buffering it.
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
ENV DOCKER true
|
||||
|
||||
#This port will be used by gunicorn.
|
||||
EXPOSE 8080
|
||||
|
||||
@@ -33,6 +35,12 @@ RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-de
|
||||
#Copy project and execute it.
|
||||
COPY . ./
|
||||
|
||||
# collect the static files
|
||||
RUN /opt/recipes/venv/bin/python manage.py collectstatic_js_reverse
|
||||
RUN /opt/recipes/venv/bin/python manage.py collectstatic --noinput
|
||||
# copy the collected static files to a different location, so they can be moved into a potentially mounted volume
|
||||
RUN mv /opt/recipes/staticfiles /opt/recipes/staticfiles-collect
|
||||
|
||||
# collect information from git repositories
|
||||
RUN /opt/recipes/venv/bin/python version.py
|
||||
# delete git repositories to reduce image size
|
||||
|
||||
21
boot.sh
21
boot.sh
@@ -67,12 +67,25 @@ echo "Migrating database"
|
||||
|
||||
python manage.py migrate
|
||||
|
||||
echo "Generating static files"
|
||||
if [[ "${DOCKER}" == "true" ]]; then
|
||||
if [[ -d "/opt/recipes/staticfiles-collect" ]]; then
|
||||
echo "Copying cached static files from docker build"
|
||||
|
||||
python manage.py collectstatic_js_reverse
|
||||
python manage.py collectstatic --noinput
|
||||
mkdir -p /opt/recipes/staticfiles
|
||||
rm -rf /opt/recipes/staticfiles/*
|
||||
mv /opt/recipes/staticfiles-collect/* /opt/recipes/staticfiles
|
||||
rm -rf /opt/recipes/staticfiles-collect
|
||||
else
|
||||
echo "Static files are already up to date"
|
||||
fi
|
||||
else
|
||||
echo "Collecting static files, this may take a while..."
|
||||
|
||||
echo "Done"
|
||||
python manage.py collectstatic_js_reverse
|
||||
python manage.py collectstatic --noinput
|
||||
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
chmod -R 755 /opt/recipes/mediafiles
|
||||
|
||||
|
||||
Reference in New Issue
Block a user