mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-30 21:49:50 -05:00
feat: improve docker run speeds
This commit is contained in:
19
Dockerfile
19
Dockerfile
@@ -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
|
||||
|
||||
@@ -23,18 +25,23 @@ RUN \
|
||||
RUN sed -i '/# Development/,$d' requirements.txt
|
||||
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev libwebp-dev openssl-dev libffi-dev cargo openldap-dev python3-dev && \
|
||||
echo -n "INPUT ( libldap.so )" > /usr/lib/libldap_r.so && \
|
||||
python -m venv venv && \
|
||||
/opt/recipes/venv/bin/python -m pip install --upgrade pip && \
|
||||
venv/bin/pip install wheel==0.42.0 && \
|
||||
venv/bin/pip install setuptools_rust==1.9.0 && \
|
||||
venv/bin/pip install -r requirements.txt --no-cache-dir &&\
|
||||
python -m pip install --upgrade pip && \
|
||||
pip install wheel==0.42.0 && \
|
||||
pip install setuptools_rust==1.9.0 && \
|
||||
pip install -r requirements.txt --no-cache-dir &&\
|
||||
apk --purge del .build-deps
|
||||
|
||||
#Copy project and execute it.
|
||||
COPY . ./
|
||||
|
||||
# collect the static files
|
||||
RUN python manage.py collectstatic_js_reverse
|
||||
RUN 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
|
||||
RUN python version.py
|
||||
# delete git repositories to reduce image size
|
||||
RUN find . -type d -name ".git" | xargs rm -rf
|
||||
|
||||
|
||||
22
boot.sh
22
boot.sh
@@ -1,5 +1,9 @@
|
||||
#!/bin/sh
|
||||
source venv/bin/activate
|
||||
|
||||
# conditionally activate virtualenv, since the docker container does not need it
|
||||
if [[ "${DOCKER}" != "true" ]]; then
|
||||
source venv/bin/activate
|
||||
fi
|
||||
|
||||
TANDOOR_PORT="${TANDOOR_PORT:-8080}"
|
||||
GUNICORN_WORKERS="${GUNICORN_WORKERS:-3}"
|
||||
@@ -67,12 +71,20 @@ echo "Migrating database"
|
||||
|
||||
python manage.py migrate
|
||||
|
||||
echo "Generating static files"
|
||||
if [[ "${DOCKER}" == "true" ]]; then
|
||||
echo "Collecting static files"
|
||||
|
||||
python manage.py collectstatic_js_reverse
|
||||
python manage.py collectstatic --noinput
|
||||
mkdir -p /opt/recipes/staticfiles
|
||||
mv /opt/recipes/staticfiles-collect/* /opt/recipes/staticfiles
|
||||
rm -rf /opt/recipes/staticfiles-collect
|
||||
else
|
||||
echo "Generating static files"
|
||||
|
||||
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