DeeperGaze / archive /Dockerfile
Alleinzellgaenger's picture
First setup
fe79d9c
FROM python:3.9-slim
# install node.js for frontend
RUN apt-get update && apt-get install -y curl
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y nodejs
# don't create .pyc files on the import of source files
ENV PYTHONDONTWRITEBYTECODE=1
# see input/output in real time in terminal
ENV PYTHONUNBUFFERED=1
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
#set working directory (where COPY– RUN– EXPOSE– is run from)
WORKDIR /app
# install requirements.txt (generated that using pipreqs) using python -m syntax, because I wanna install the packages into the current working python version
COPY --chown=user:users ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY --chown=user:users . /app
COPY frontend/package.json frontend/package-lock.json ./frontend/
RUN cd frontend && npm install
COPY frontend/ ./frontend/
RUN cd frontend && npm run build
EXPOSE 7860
RUN pip install uvicorn aiofiles
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]