dsmueller commited on
Commit
dde9f64
1 Parent(s): 2c02837

Refactor Dockerfile for improved directory structure and permissions

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -8
Dockerfile CHANGED
@@ -8,16 +8,17 @@ RUN useradd -m -u 1000 user
8
  # Switch to the "user" user
9
  USER user
10
 
11
- # Set home to the user's home directory
 
12
  ENV HOME=/data \
13
  PATH=/data:$PATH
14
 
15
  # Change permissions for to read/write/execute
16
- RUN mkdir -p $HOME/app
17
- RUN chmod 777 $HOME/app
18
 
19
  # Set the working directory to the user's home directory
20
- WORKDIR $HOME/app
21
 
22
  # Install poetry
23
  RUN pip3 install poetry
@@ -30,16 +31,16 @@ COPY --chown=user pyproject.toml poetry.lock ./
30
  RUN poetry config virtualenvs.in-project true
31
 
32
  # Set the name of the virtual environment
33
- RUN poetry config virtualenvs.path $HOME/app/.venv
34
 
35
  # Install dependencies
36
  RUN poetry install
37
 
38
  # Set the .venv folder as the virtual environment directory
39
- ENV PATH="$HOME/app/.venv/bin:$PATH"
40
 
41
  # Copy the current directory contents into the container
42
- COPY --chown=user . $HOME/app
43
 
44
  # Make a port available to the world outside this container
45
  # The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. Your container needs to listen to Streamlit’s (default) port 8501.
@@ -49,7 +50,7 @@ EXPOSE 8501
49
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
50
 
51
  # Update working directory to be consistent with where Start.py is
52
- WORKDIR $HOME/app/scripts
53
 
54
  # An ENTRYPOINT allows you to configure a container that will run as an executable. Here, it also contains the entire streamlit run command for your app, so you don’t have to call it from the command line
55
  ENTRYPOINT ["streamlit", "run", "Start.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
8
  # Switch to the "user" user
9
  USER user
10
 
11
+ # Set home to the user's home directory.
12
+ # See here for persistent storage: https://huggingface.co/docs/hub/spaces-storage
13
  ENV HOME=/data \
14
  PATH=/data:$PATH
15
 
16
  # Change permissions for to read/write/execute
17
+ # RUN mkdir -p $HOME/app
18
+ RUN chmod 777 $HOME/
19
 
20
  # Set the working directory to the user's home directory
21
+ WORKDIR $HOME/
22
 
23
  # Install poetry
24
  RUN pip3 install poetry
 
31
  RUN poetry config virtualenvs.in-project true
32
 
33
  # Set the name of the virtual environment
34
+ RUN poetry config virtualenvs.path $HOME//.venv
35
 
36
  # Install dependencies
37
  RUN poetry install
38
 
39
  # Set the .venv folder as the virtual environment directory
40
+ ENV PATH="$HOME//.venv/bin:$PATH"
41
 
42
  # Copy the current directory contents into the container
43
+ COPY --chown=user . $HOME/
44
 
45
  # Make a port available to the world outside this container
46
  # The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. Your container needs to listen to Streamlit’s (default) port 8501.
 
50
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
51
 
52
  # Update working directory to be consistent with where Start.py is
53
+ WORKDIR $HOME/scripts
54
 
55
  # An ENTRYPOINT allows you to configure a container that will run as an executable. Here, it also contains the entire streamlit run command for your app, so you don’t have to call it from the command line
56
  ENTRYPOINT ["streamlit", "run", "Start.py", "--server.port=8501", "--server.address=0.0.0.0"]