privateone commited on
Commit
2389d11
·
verified ·
1 Parent(s): 24e1fea

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +52 -0
Dockerfile ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11
2
+
3
+ ENV USERNAME=admin
4
+ # Create and use a non-root user
5
+ RUN useradd -ms /bin/bash $USERNAME
6
+
7
+ # Set working directory for the application
8
+ WORKDIR /app
9
+
10
+ # Copy only the necessary files first for better cache utilization
11
+ COPY requirements.txt /app/requirements.txt
12
+
13
+ # Install system dependencies and clean up in a single RUN step to reduce layers
14
+ RUN apt-get update -y && apt-get upgrade -y \
15
+ && apt-get install -y git-all \
16
+ && apt-get clean \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
+
20
+ # ENV GITHUB_PAT=${GITHUB_PAT}
21
+ # RUN echo "GITHUB_PAT is:"$GITHUB_PAT
22
+ # RUN git clone https://blendersb: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@github.com/blendersb/teleapi.git
23
+
24
+ # ARG GITHUB_PAT
25
+ ENV HOME=/home/$USERNAME
26
+ RUN mkdir $HOME/.cache $HOME/.config \
27
+ && chmod -R 777 $HOME
28
+
29
+ ENV PATH=$HOME/.local/bin:$PATH
30
+
31
+ COPY init.sh /app/init.sh
32
+ RUN chmod +x /app/init.sh
33
+ RUN /app/init.sh
34
+
35
+ # Install Python dependencies from the requirements file
36
+ # RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
37
+
38
+ # Copy the rest of the application code after installing dependencies for better cache
39
+ # COPY . /app
40
+
41
+ # Set ownership and permissions for the app directory
42
+ RUN chown -R admin:admin /app && chmod -R 777 /app
43
+
44
+ # Switch to the non-root user for better security
45
+ USER admin
46
+
47
+ # Expose the port the application will run on
48
+ EXPOSE 7860
49
+
50
+ # Use init.sh as the entrypoint so it runs on container start
51
+ ENTRYPOINT ["/app/init.sh"]
52
+ CMD ["python", "-u", "-m", "FileStream"]