Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
clean up dockerfile; bugfix "pip cache" throws error, instead rely on…
Browse files Browse the repository at this point in the history
… env variable PIP_NO_CACHE_DIR=false as in pypa/pip#5735
  • Loading branch information
aalok-sathe committed Feb 3, 2022
1 parent 94892d5 commit 8681986
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# syntax=docker/dockerfile:1
FROM ubuntu:20.04 as builddeps
FROM ubuntu:20.04

# source: https://stackoverflow.com/a/54763270/2434875

################################################################
#### set up environment ####
#### source: https://stackoverflow.com/a/54763270/2434875
#### source: https://github.com/pypa/pip/issues/5735
################################################################
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
Expand All @@ -11,7 +16,11 @@ ENV PYTHONFAULTHANDLER=1 \
POETRY_VERSION=1.1.10

WORKDIR /app
# install necessary packages using apt


################################################################
#### install system-wide dependencies and utilities; cache ####
################################################################
RUN apt update
RUN apt install -y python3.8 python3.8-dev python3-pip
RUN apt install -y python2.7 python2.7-dev
Expand All @@ -26,35 +35,32 @@ COPY poetry.lock pyproject.toml /app/
COPY sentspace /app/sentspace
# RUN python3.8 -m venv /venv

FROM builddeps as build

RUN ls -lah . ..
################################################################
#### install package dependencies; build using poetry ####
################################################################
RUN ls -lah .
RUN pip config set global.cache-dir false
RUN poetry config virtualenvs.create false
RUN poetry install -E polyglot --no-interaction --no-ansi --no-root && \
poetry build -f wheel && \
pip install --no-deps . dist/*.whl && \
rm -rf dist *.egg-info
# ADD ./requirements.txt /app/requirements/requirements.txt
# unnecessary: # ADD . /app/

# install ZS package separately (pypi install fails)
# RUN python3.8 -m pip install -U pip cython
# RUN apt install -y git
# RUN git clone https://github.com/njsmith/zs
# RUN cd zs && git checkout v0.10.0 && pip install .
# RUN rm -rf zs
# install rest of the requirements using pip
# RUN pip install -r ./requirements.txt

RUN polyglot download morph2.en
# RUN pip install -U ipython ipykernel jupyter

# cleanup

################################################################
#### cleanup ####
################################################################
RUN apt remove -y git
RUN apt autoremove -y
RUN pip cache purge
RUN apt clean && rm -rf /var/lib/apt/lists/*


################################################################
#### set up entrypoint to use as standalone app ####
################################################################
EXPOSE 8051
ENTRYPOINT [ "python3.8", "-m", "sentspace" ]
CMD [ "-h" ]

0 comments on commit 8681986

Please sign in to comment.