Forked from ruddra/Docker with Django, Numpy, Scipy, Gensim and Pandas
Created
March 11, 2022 23:38
-
-
Save nikolaysm/fdf140f020927580a0ecbe16eedd5df5 to your computer and use it in GitHub Desktop.
Docker with Django, Numpy, Scipy, Gensim and Pandas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pull official python alpine image | |
FROM python:3.7-alpine | |
# Set Environment Variable | |
ENV PYTHONUNBUFFERED 1 | |
ENV C_FORCE_ROOT true | |
# Making source and static directory | |
RUN mkdir /src | |
RUN mkdir /static | |
# Creating Work Directory | |
WORKDIR /src | |
# Adding mandatory packages to docker | |
RUN apk update && apk add --no-cache \ | |
postgresql \ | |
zlib \ | |
jpeg \ | |
openblas \ | |
libstdc++ | |
# Installing temporary packages required for installing requirements.pip | |
RUN apk add --no-cache --virtual build-deps \ | |
gcc \ | |
python3-dev \ | |
musl-dev \ | |
postgresql-dev\ | |
zlib-dev \ | |
jpeg-dev \ | |
g++ \ | |
openblas-dev \ | |
cmake \ | |
&& ln -s /usr/include/locale.h /usr/include/xlocale.h | |
# Update pip | |
RUN pip install --upgrade pip | |
# Installing scipy | |
RUN pip3 install --no-cache-dir --disable-pip-version-check scipy==1.3.1 | |
# Installing numpy, scipy, psycopg2, gensim | |
RUN pip3 install --no-cache-dir \ | |
pandas==0.25.2 \ | |
numpy==1.17.3 \ | |
psycopg2==2.8.4 \ | |
gensim==3.8.1 # remove it if not necessary | |
# Installing requirements.pip from project | |
COPY ./src/requirements.pip /scripts/ | |
RUN pip install --no-cache-dir -r /scripts/requirements.pip | |
# removing temporary packages from docker and removing cache | |
RUN apk del build-deps && \ | |
find -type d -name __pycache__ -prune -exec rm -rf {} \; && \ | |
rm -rf ~/.cache/pip | |
# CMD will run when this dockerfile is running | |
CMD ["sh", "-c", "python manage.py collectstatic --no-input; python manage.py migrate; gunicorn mydjango.wsgi -b 0.0.0.0:8000 & celery worker --app=myapp.tasks"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment