File size: 1,183 Bytes
a7f0006
 
 
 
 
 
 
11f09d6
a7f0006
 
 
11f09d6
5733977
91acc0d
 
 
 
 
 
 
 
 
11f09d6
 
 
 
 
 
a7f0006
91acc0d
 
 
a7f0006
 
 
 
 
5733977
 
 
a7f0006
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Use Ubuntu as base image for better compatibility
FROM ubuntu:22.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PORT=7860

# Install required dependencies and download sshx as root
RUN apt-get update && apt-get install -y \
    curl \
    ca-certificates \
    tar \
    python3 \
    sudo \
    nano \
    vim \
    git \
    wget \
    htop \
    net-tools \
    iputils-ping \
    build-essential \
    && rm -rf /var/lib/apt/lists/* \
    && curl -sSL https://s3.amazonaws.com/sshx/sshx-x86_64-unknown-linux-musl.tar.gz -o /tmp/sshx.tar.gz \
    && tar -xzf /tmp/sshx.tar.gz -C /tmp \
    && mv /tmp/sshx /usr/local/bin/sshx \
    && chmod +x /usr/local/bin/sshx \
    && rm -f /tmp/sshx.tar.gz

# Create a non-root user and add to sudoers
RUN useradd -m -u 1000 user \
    && echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Switch to user
USER user
WORKDIR /home/user

# Copy web interface
COPY --chown=user:user index.html /home/user/index.html

# Expose port for Hugging Face Space
EXPOSE 7860

# Create startup script
COPY --chown=user:user start.sh /home/user/start.sh
RUN chmod +x /home/user/start.sh

# Run sshx
CMD ["/home/user/start.sh"]