huathedev's picture
Update Dockerfile
759487d
raw
history blame
1.43 kB
# temporary building stage
FROM python:3.8.5-slim as builder
# install system dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends build-essential gcc
RUN apt-get install -y git
WORKDIR /app
# create a virtual environment for python
RUN python -m venv /usr/service/venv
ENV PATH="/usr/service/venv/bin:$PATH"
#ENV PATH=“${PATH}:/root/.local/bin”
# install python packages into virtual environment
COPY requirements.txt .
RUN pip install -r requirements.txt --no-cache-dir
RUN pip install numpy==1.20.0
RUN pip install cython==0.29.21
RUN pip install pygco==0.0.16
# final stage
FROM python:3.8.5-slim@sha256:0e07cc072353e6b10de910d8acffa020a42467112ae6610aa90d6a3c56a74911
RUN apt-get update
# create a high-privileged user called "python"
RUN useradd -o -r -u 0 python
# make the service directory and give "python" user access rights to the directory
RUN mkdir /app && chown python:python /app
WORKDIR /app
# copy python environment and source files to service directory, and give "python" user
# access rights to these files.
COPY --chown=python:python apps/demo apps/demo
# use the high-privileged "python" user
USER 0
# use python environment and start service
EXPOSE 8501
#ENV PATH="/usr/service/venv/bin:$PATH"
#ENV PATH=“${PATH}:/root/.local/bin”
#ENV PYTHONPATH=.
ENTRYPOINT ["streamlit", "run", "apps/demo/ⓘ_Introduction.py", "--server.port=8501", "--server.address=0.0.0.0"]