thewise commited on
Commit
be542ab
1 Parent(s): e6f585a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -13
Dockerfile CHANGED
@@ -1,26 +1,42 @@
 
1
  FROM python:3.10-slim
2
 
 
3
  RUN apt-get update && apt-get install -y \
4
  build-essential \
5
  curl \
6
- software-properties-common \
7
  git \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # This sets the /app directory as the working directory for any RUN, CMD, ENTRYPOINT, or COPY instructions that follow.
11
- WORKDIR /app
12
 
13
- #GITHUB REPO Folder
14
- RUN mkdir /app/github_repo && chmod 777 /app/github_repo
15
 
16
- # This copies everything in your current directory to the /app directory in the container.
17
- COPY . /app
 
18
 
19
- # This runs pip install for all the packages listed in your requirements.txt file.
20
- RUN pip install --upgrade pip
21
- RUN pip install -r requirements.txt
22
 
23
- #EXPOSE 8501
24
- #I commented out EXPOSE 8501, and gave 7860 in CMD, since it works. Funny? The building of Streamlit never stops with 8501!!!
25
 
26
- ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image as the base image
2
  FROM python:3.10-slim
3
 
4
+ # Install essential build tools
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
 
8
  git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # Set up a new user named "user" with user ID 1000
12
+ RUN useradd -m -u 1000 user
13
 
14
+ # Switch to the "user" user
15
+ USER user
16
 
17
+ # Set home to the user's home directory and update PATH
18
+ ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
 
21
+ # Set the working directory to the user's home directory/app
22
+ WORKDIR $HOME/app
 
23
 
24
+ # Upgrade pip and install dependencies from requirements.txt
25
+ RUN pip install --no-cache-dir --upgrade pip
26
 
27
+ # Copy the requirements.txt and app.py into the container at $HOME/app
28
+ # Use the --chown flag to ensure the copied files are owned by the user
29
+ COPY --chown=user requirements.txt $HOME/app/
30
+ COPY --chown=user app.py $HOME/app/
31
+ COPY --chown=user ./src/ $HOME/app/
32
+
33
+ # Install Python dependencies
34
+ RUN pip install --no-cache-dir -r requirements.txt
35
+
36
+ RUN mkdir $HOME/app/github_repo
37
+
38
+ # Use the user's home directory as the working directory
39
+ WORKDIR $HOME/app
40
+
41
+ # Run your app. Adjust the command if your app starts differently.
42
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]