no-name-here commited on
Commit
5598804
·
verified ·
1 Parent(s): bfa6ae5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +69 -12
Dockerfile CHANGED
@@ -1,18 +1,75 @@
1
- # Dockerfile
2
- FROM python:3.9-slim
3
 
4
- # Set a working directory
5
- # WORKDIR /app
6
 
7
- # Copy dependency definitions and install them
8
- COPY requirements.txt .
9
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
10
 
11
- # Copy the application code
12
- COPY . .
 
 
13
 
14
- # Expose the port that uvicorn will listen on (Hugging Face Spaces uses port 7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  EXPOSE 7860
16
 
17
- # Start the FastAPI app with uvicorn
18
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Base image
2
+ FROM python:3.9
3
 
4
+ ENV DEBIAN_FRONTEND=noninteractive
 
5
 
6
+ # Install only what's needed
7
+ RUN apt-get update && apt-get install -y \
8
+ openssh-server \
9
+ curl \
10
+ wget \
11
+ git \
12
+ nano \
13
+ net-tools \
14
+ sudo \
15
+ ca-certificates \
16
+ libcap2-bin && \
17
+ rm -rf /var/lib/apt/lists/*
18
 
19
+ # SSH setup
20
+ RUN mkdir -p /var/run/sshd && \
21
+ ssh-keygen -A && \
22
+ chmod 600 /etc/ssh/ssh_host_*_key
23
 
24
+ # Configure sshd keep on port 22 internally (HF maps 7860 externally)
25
+ RUN sed -i -E 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && \
26
+ sed -i -E 's/#?UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
27
+ sed -i -E 's/#?PermitEmptyPasswords .*/PermitEmptyPasswords no/' /etc/ssh/sshd_config && \
28
+ sed -i -E 's/#?ChallengeResponseAuthentication .*/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
29
+ sed -i -E 's/#?PermitRootLogin .*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
30
+
31
+ # Create non-root user
32
+ RUN useradd -m -u 1000 -s /bin/bash user && \
33
+ echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/user
34
+
35
+ # Add your SSH public key
36
+ RUN mkdir -p /home/user/.ssh && \
37
+ echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC8MNnoeALNROR4f5rSdeyTWpB/EfK83UAV9wOMvzgBmKx2bUZLnlQNDnfHzize3iAk0KWjjEped+O9ZIK1PZmGbmrU6qM5MvtV5H3a9ySLlVwzGuvjHEYPR8zprfQPTJYXYfukxfczSyIWNyunpuQoB+O8gLoY9urIQmuwYaX1qTKpooxpBG/tuRgy7LkTmqp0CGD60ugTYS9cJRVfpcssBcbTtQi0kgnr44ml9MRmR7rh53Vo3vqeo3BGAhINTdWdGvR2k7dTU3jVe+CdzYn8U5IeSG7KlkM6VB53gmJWQ8wPSj+Xhp7yB7AYPqKKzj27lud1yA9DSosVf5vKYxvagqx5GMfDHsTsOuWeXfKIZYdzX/XsKr5QZaH4r7K9j65+t4yn2LC5p9oAv8+GK/sUi8/uj20i3sglhHW/ZYxhJ9h3HYEjFmg2bJX5FO0X67YjN7piBQ+5T/mXBXD6mHHYgAOpmC+glLdq39cjoXD4AAV9xPNTjfEQ0sUi+YZU4VE8xu/f9cZuS0+x4Qv35fHrYr7dqwsLGuibLPt4lfXtLHbBUKjzmv1nSXc3YDwbqD3Uic6MA0F+yYHgBubqT5WAtitzeLYEaWK7gfK4qvz0AI0wLdTvFfvlIEKJCP0dKplGXE92JCkNEsK8b4P3U43D1lmLCn0kN64lsK6oxXWXzw== your_email@example.com" \
38
+ > /home/user/.ssh/authorized_keys && \
39
+ chmod 700 /home/user/.ssh && \
40
+ chmod 600 /home/user/.ssh/authorized_keys && \
41
+ chown -R user:user /home/user/.ssh
42
+
43
+ # Also allow root SSH login with the same key (for tunnel use)
44
+ RUN mkdir -p /root/.ssh && \
45
+ cp /home/user/.ssh/authorized_keys /root/.ssh/authorized_keys && \
46
+ chmod 700 /root/.ssh && chmod 600 /root/.ssh/authorized_keys
47
+
48
+ # Install gsocket properly
49
+ RUN wget -qO /tmp/gsocket_install.sh https://gsocket.io/install.sh && \
50
+ bash /tmp/gsocket_install.sh || true && \
51
+ # Fallback: build from source if binary not in PATH
52
+ which gs-netcat || ( \
53
+ apt-get update && apt-get install -y automake autoconf build-essential libssl-dev && \
54
+ git clone --depth=1 https://github.com/hackerschoice/gsocket.git /tmp/gsocket && \
55
+ cd /tmp/gsocket && autoreconf -fi && ./configure && make && make install \
56
+ )
57
+
58
+ # Install code-server (VS Code in browser)
59
+ RUN curl -fsSL https://code-server.dev/install.sh | sh
60
+
61
+ # ---------------------------------------------------------------
62
+ # CRITICAL for HF Spaces: port 7860 must respond with HTTP.
63
+ # We run a tiny Python HTTP server on 7860 alongside sshd on 22.
64
+ # ---------------------------------------------------------------
65
+
66
+ WORKDIR /app
67
+ COPY . /app
68
+
69
+ COPY entrypoint.sh /entrypoint.sh
70
+ RUN chmod +x /entrypoint.sh
71
+
72
+ # HF Spaces requires EXPOSE 7860
73
  EXPOSE 7860
74
 
75
+ CMD ["/entrypoint.sh"]