Bayhaqy commited on
Commit
5a925a3
·
verified ·
1 Parent(s): 61ea3cd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +51 -72
Dockerfile CHANGED
@@ -1,93 +1,72 @@
1
  # Using the Ubuntu image
2
  FROM ubuntu:latest
3
 
4
- # set language, format and stuff
5
- ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
6
-
7
- # Update package manager (apt-get)
8
- RUN apt-get update -y
9
- RUN apt-get upgrade -y
10
- RUN apt update
11
-
12
- # installing python3 with a specific version
13
- RUN apt install python3.12 -y
14
- # RUN apt install python3.12-distutils -y
15
- #RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
16
-
17
- # installing other libraries
18
- RUN apt-get install python3-pip -y && apt-get -y install sudo
19
- RUN apt-get install python3-dev -y
20
- RUN apt-get install python3-venv -y
21
- RUN apt-get install curl -y
22
- RUN apt-get install gnupg -y
23
- RUN apt-get install nano -y
24
- RUN apt-get install ca-certificates -y
25
- RUN apt-get update && apt-get install -y git
26
-
27
- # Create directories and import GPG key
28
- RUN mkdir -p /etc/apt/keyrings
29
- RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
30
 
31
  # Add the Node.js repository
32
  RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
33
 
34
- # Install Node.js
35
- RUN apt-get update && apt-get install nodejs -y
 
 
36
 
37
- # Install tweet-harvest@latest
38
- RUN npm install -g tweet-harvest@latest
39
- RUN npm install -g npm@latest
40
 
41
- # Set up a new user named "user" with user ID 1000
42
- RUN useradd -m -u 1000 user
 
 
43
 
44
- # Switch to the "user" user
45
- USER user
46
 
47
- # Set home to the user's home directory
48
- ENV HOME=/home/user \
49
- PATH=/home/user/.local/bin:$PATH
50
-
51
- # Download from Github
52
- RUN git clone https://github.com/bayhaqy/X-Dashboard.git $HOME/app
53
-
54
- RUN pwd
55
-
56
- RUN ls -lhat .
57
-
58
- RUN ls -lhat $HOME
59
-
60
- RUN ls -lhat $HOME/app
61
 
62
  WORKDIR $HOME/app
63
 
64
- # Add permission
65
- RUN chown user $HOME/app
66
- RUN chmod -R 777 ${HOME}
67
-
68
- RUN pwd
69
-
70
- # Setting virtual environment
71
- RUN python3 -m venv .venv
72
- ENV PATH="$HOME/app/.venv/bin:$PATH"
73
-
74
- # Install any needed packages specified in requirements.txt
75
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
76
-
77
- # Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
78
- RUN pip install --no-cache-dir --upgrade pip
79
 
80
- RUN pwd
 
 
81
 
82
- RUN ls -lhat
83
- RUN ls -lhat $HOME/app
 
84
 
85
- # Check version
86
- RUN python3 --version
87
- RUN node -v
88
- RUN npm list -g
89
 
90
- # Make port 8501 available to the world outside this container
91
  EXPOSE 8501
92
 
93
  # Define the command to run your Streamlit app
 
1
  # Using the Ubuntu image
2
  FROM ubuntu:latest
3
 
4
+ # Set language, format and stuff
5
+ ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 \
6
+ DEBIAN_FRONTEND=noninteractive
7
+
8
+ # Update package manager and install basic dependencies
9
+ RUN apt-get update -y && \
10
+ apt-get upgrade -y && \
11
+ apt-get install -y --no-install-recommends \
12
+ python3.12 \
13
+ python3-pip \
14
+ python3-dev \
15
+ python3-venv \
16
+ curl \
17
+ gnupg \
18
+ nano \
19
+ ca-certificates \
20
+ git \
21
+ sudo \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
24
+ # Create directories and import GPG key for Node.js
25
+ RUN mkdir -p /etc/apt/keyrings && \
26
+ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
 
 
 
27
 
28
  # Add the Node.js repository
29
  RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
30
 
31
+ # Install Node.js and npm
32
+ RUN apt-get update && \
33
+ apt-get install -y nodejs && \
34
+ rm -rf /var/lib/apt/lists/*
35
 
36
+ # Install tweet-harvest and update npm
37
+ RUN npm install -g tweet-harvest@latest npm@latest
 
38
 
39
+ # Create and switch to a non-root user (using the first available UID)
40
+ RUN adduser --disabled-password --gecos '' appuser && \
41
+ mkdir -p /home/appuser/app && \
42
+ chown -R appuser:appuser /home/appuser
43
 
44
+ # Switch to the appuser
45
+ USER appuser
46
 
47
+ # Set environment variables
48
+ ENV HOME=/home/appuser \
49
+ PATH=/home/appuser/.local/bin:$PATH
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  WORKDIR $HOME/app
52
 
53
+ # Clone repository
54
+ RUN git clone https://github.com/bayhaqy/X-Dashboard.git .
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ # Create virtual environment
57
+ RUN python3 -m venv .venv
58
+ ENV PATH="$HOME/app/.venv/bin:$PATH"
59
 
60
+ # Upgrade pip and install requirements
61
+ RUN pip install --no-cache-dir --upgrade pip && \
62
+ pip install --no-cache-dir -r requirements.txt
63
 
64
+ # Check versions (for debugging, remove in production)
65
+ RUN python3 --version && \
66
+ node -v && \
67
+ npm list -g
68
 
69
+ # Expose port
70
  EXPOSE 8501
71
 
72
  # Define the command to run your Streamlit app