dsmueller commited on
Commit
2fb8bff
·
1 Parent(s): 3d9d79d

Initial commit

Browse files
Files changed (1) hide show
  1. Dockerfile +72 -0
Dockerfile ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.11.5-bookworm
3
+
4
+ # Do root things: clone repo and install dependencies. libsndfile1 for spotlight. libhdf5-serial-dev for vector distance.
5
+ # USER root
6
+
7
+ RUN useradd -m -u 1000 user && chown -R user:user /home/user && chmod -R 777 /home/user
8
+
9
+ RUN apt-get update && apt-get install -y \
10
+ libhdf5-serial-dev \
11
+ libsndfile1 \
12
+ curl \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ USER user
16
+
17
+ # Set home to the user's home directory
18
+ ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
+ WORKDIR $HOME
21
+
22
+ # Create directories for the app code to be copied into
23
+ RUN mkdir $HOME/app
24
+ RUN mkdir $HOME/config
25
+ RUN mkdir $HOME/db
26
+ RUN mkdir $HOME/src
27
+
28
+ # Give all users read/write permissions to the app code directories
29
+ RUN chmod 777 $HOME/app
30
+ RUN chmod 777 $HOME/config
31
+ RUN chmod 777 $HOME/db
32
+ RUN chmod 777 $HOME/src
33
+
34
+ # Set environment variables
35
+ ENV PATH="$HOME/.venv/bin:$PATH"
36
+
37
+ # Install Poetry and configure it to install to a user-writable location
38
+ RUN curl -sSL https://install.python-poetry.org | python3 - \
39
+ && poetry config virtualenvs.create true \
40
+ && poetry config cache-dir /home/user/.cache/poetry \
41
+ && poetry config virtualenvs.path /home/user/.local/share/virtualenvs
42
+
43
+ # Copy Poetry files and install dependencies with correct permissions
44
+ COPY --chown=user:user pyproject.toml poetry.lock ./
45
+ RUN python3 -m pip install --user --no-warn-script-location poetry \
46
+ && poetry config virtualenvs.in-project true \
47
+ && poetry install --no-interaction --no-ansi
48
+
49
+ # Copy the rest of your application code.
50
+ COPY --chown=user:user ./aerospace_chatbot/app $HOME/app
51
+ COPY --chown=user:user ./aerospace_chatbot/config $HOME/config
52
+ COPY --chown=user:user ./aerospace_chatbot/db $HOME/db
53
+ COPY --chown=user:user ./aerospace_chatbot/src $HOME/src
54
+
55
+ # Set up run env variables.
56
+ ENV LOCAL_DB_PATH=$HOME/db
57
+ ENV AEROSPACE_CHATBOT_CONFIG='admin'
58
+ ENV PYTHONPATH=$HOME/src:$PYTHONPATH
59
+
60
+ # Set final work directory for the application
61
+ WORKDIR $HOME/app
62
+ RUN pwd
63
+ RUN ls -R
64
+
65
+ # Expose the port Streamlit runs on
66
+ EXPOSE 8501
67
+
68
+ # The HEALTHCHECK instruction tells Docker how to test a container to check that it is still working.
69
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
70
+
71
+ # An ENTRYPOINT allows you to configure a container that will run as an executable.
72
+ ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]