Create Dockerfile
Browse files- Dockerfile +48 -0
Dockerfile
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
# 1. Install SSH and supervisor (to run two processes at once)
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
openssh-server \
|
| 6 |
+
supervisor \
|
| 7 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
# 2. SSHD requires this directory to exist to run
|
| 10 |
+
RUN mkdir -p /run/sshd
|
| 11 |
+
|
| 12 |
+
# 3. Create the standard HF user (UID 1000)
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
|
| 15 |
+
# 4. Set up the SSH authorized_keys for the user
|
| 16 |
+
RUN mkdir -p /home/user/.ssh && chmod 700 /home/user/.ssh
|
| 17 |
+
|
| 18 |
+
# PASTE YOUR ~/.ssh/id_rsa.pub (or id_ed25519.pub) STRING DIRECTLY IN THE QUOTES BELOW:
|
| 19 |
+
RUN echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINSySUA8UiToR745UcU9Y10BCb6k0BHVOClO33PPH//v github-push-2026-06-20" > /home/user/.ssh/authorized_keys
|
| 20 |
+
|
| 21 |
+
RUN chmod 600 /home/user/.ssh/authorized_keys
|
| 22 |
+
RUN chown -R user:user /home/user/.ssh
|
| 23 |
+
|
| 24 |
+
# 5. Configure SSHD to listen on HF's only open port (7860)
|
| 25 |
+
# and allow key-based login for 'user'
|
| 26 |
+
RUN echo "Port 7860\n\
|
| 27 |
+
ListenAddress 0.0.0.0\n\
|
| 28 |
+
PermitRootLogin no\n\
|
| 29 |
+
PasswordAuthentication no\n\
|
| 30 |
+
PubkeyAuthentication yes\n\
|
| 31 |
+
AllowUsers user" > /etc/ssh/sshd_config.d/custom.conf
|
| 32 |
+
|
| 33 |
+
# 6. Copy your supervisor config (created in Step 2)
|
| 34 |
+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 35 |
+
|
| 36 |
+
# 7. HF strictly requires the container to run as user 1000, NOT root.
|
| 37 |
+
# However, sshd strictly requires root to boot.
|
| 38 |
+
# Fix: Give 'user' ownership of the sshd run folder so a non-root user can boot it.
|
| 39 |
+
RUN chown -R user:user /run/sshd /etc/ssh
|
| 40 |
+
|
| 41 |
+
USER user
|
| 42 |
+
WORKDIR /home/user/app
|
| 43 |
+
|
| 44 |
+
COPY --chown=user . .
|
| 45 |
+
|
| 46 |
+
EXPOSE 7860
|
| 47 |
+
|
| 48 |
+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|