Skip to content

Commit

Permalink
Merge pull request #3055 from tooboredtocode/develop
Browse files Browse the repository at this point in the history
Improve docker run speeds
  • Loading branch information
vabene1111 authored Apr 4, 2024
2 parents 4293ec7 + f8b8d3f commit d766927
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,21 @@ echo "Migrating database"

python manage.py migrate

echo "Generating static files"
if [[ "${DOCKER}" == "true" ]]; 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 "Collecting static files, this may take a while..."

python manage.py collectstatic_js_reverse
python manage.py collectstatic --noinput

echo "Done"
echo "Done"
fi

chmod -R 755 /opt/recipes/mediafiles

Expand Down

0 comments on commit d766927

Please sign in to comment.