Amogh Agastya commited on
Commit
c6be573
1 Parent(s): 2631838

updated dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -10
Dockerfile CHANGED
@@ -1,21 +1,46 @@
1
- FROM python:3.11-slim-buster
 
 
 
 
 
 
 
 
 
 
2
 
3
  WORKDIR /app
4
 
5
- COPY app/requirements.txt /app/requirements.txt
6
 
7
- RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt
 
 
 
8
 
9
- # User
10
  RUN useradd -m -u 1000 user
 
11
  USER user
12
- ENV HOME /home/user
13
- ENV PATH $HOME/.local/bin:$PATH
14
 
15
- WORKDIR $HOME
16
- RUN mkdir app
 
 
 
 
17
  WORKDIR $HOME/app
18
- COPY . $HOME/app
19
 
20
- EXPOSE 8000
 
 
 
 
 
 
 
 
 
 
 
21
  CMD ["chainlit", "run", "app/spark.py"]
 
1
+ # The builder image, used to build the virtual environment
2
+ FROM python:3.11-slim-buster as builder
3
+
4
+ RUN apt-get update && apt-get install -y git
5
+
6
+ RUN pip install poetry==1.4.2
7
+
8
+ ENV POETRY_NO_INTERACTION=1 \
9
+ POETRY_VIRTUALENVS_IN_PROJECT=1 \
10
+ POETRY_VIRTUALENVS_CREATE=1 \
11
+ POETRY_CACHE_DIR=/tmp/poetry_cache
12
 
13
  WORKDIR /app
14
 
15
+ COPY pyproject.toml poetry.lock ./
16
 
17
+ RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
18
+
19
+ # The runtime image, used to just run the code provided its virtual environment
20
+ FROM python:3.11-slim-buster as runtime
21
 
 
22
  RUN useradd -m -u 1000 user
23
+
24
  USER user
 
 
25
 
26
+ ENV HOME=/home/user \
27
+ PATH="/home/user/.local/bin:$PATH" \
28
+ VIRTUAL_ENV=/app/.venv \
29
+ LISTEN_PORT=8000 \
30
+ HOST=0.0.0.0
31
+
32
  WORKDIR $HOME/app
 
33
 
34
+ COPY --from=builder --chown=user ${VIRTUAL_ENV} ${VIRTUAL_ENV}
35
+
36
+ COPY --chown=user ./app ./app
37
+ COPY --chown=user ./.chainlit ./.chainlit
38
+ COPY --chown=user ./.env ./.env
39
+ COPY --chown=user chainlit.md ./
40
+
41
+ EXPOSE $LISTEN_PORT
42
+
43
+ # If chainlit is a Python package that needs to be installed, uncomment the following line:
44
+ RUN pip install -r app/requirements.txt
45
+
46
  CMD ["chainlit", "run", "app/spark.py"]