Claude commited on
Commit
7f56859
·
1 Parent(s): 205b164

Add application file

Browse files
Files changed (3) hide show
  1. Dockerfile +12 -92
  2. app.py +7 -0
  3. requirements.txt +2 -0
Dockerfile CHANGED
@@ -1,99 +1,19 @@
1
- FROM ubuntu:22.04
 
2
 
3
- # Avoid interactive prompts during package installation
4
- ENV DEBIAN_FRONTEND=noninteractive
5
 
6
- # Install base packages and development tools
7
- RUN apt-get update && apt-get install -y \
8
- curl \
9
- wget \
10
- git \
11
- vim \
12
- nano \
13
- htop \
14
- tree \
15
- unzip \
16
- sudo \
17
- build-essential \
18
- software-properties-common \
19
- apt-transport-https \
20
- ca-certificates \
21
- gnupg \
22
- lsb-release \
23
- zsh \
24
- fish \
25
- && rm -rf /var/lib/apt/lists/*
26
 
27
- # Install Python and pip
28
- RUN apt-get update && apt-get install -y \
29
- python3 \
30
- python3-pip \
31
- python3-venv \
32
- python3-dev \
33
- && rm -rf /var/lib/apt/lists/*
34
 
35
- # Install Node.js
36
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
37
- && apt-get install -y nodejs \
38
- && rm -rf /var/lib/apt/lists/*
39
 
40
- # Install additional programming languages
41
- RUN apt-get update && apt-get install -y \
42
- openjdk-11-jdk \
43
- golang-go \
44
- ruby \
45
- php \
46
- && rm -rf /var/lib/apt/lists/*
47
 
48
- # Install useful development tools
49
- RUN pip3 install --no-cache-dir \
50
- pip \
51
- setuptools \
52
- wheel \
53
- virtualenv \
54
- pipenv \
55
- poetry \
56
- jupyter \
57
- ipython
58
 
59
- # Install ttyd for web-based terminal
60
- RUN apt-get update && apt-get install -y \
61
- ttyd \
62
- screen \
63
- tmux \
64
- openssh-server \
65
- pwgen \
66
- && rm -rf /var/lib/apt/lists/*
67
-
68
- # Create development user
69
- RUN useradd -m -s /bin/bash devuser && \
70
- echo "devuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
71
-
72
- # Configure SSH server
73
- RUN mkdir /var/run/sshd && \
74
- sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
75
- sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
76
- sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config && \
77
- echo "root:ubuntu" | chpasswd
78
-
79
- # Expose SSH port
80
- EXPOSE 22 7681
81
-
82
- # Set up workspace
83
- WORKDIR /workspace
84
- RUN chown -R devuser:devuser /workspace
85
-
86
- # Switch to devuser
87
- USER devuser
88
-
89
- # Create startup script
90
- RUN echo '#!/bin/bash\n\
91
- service ssh start\n\
92
- exec ttyd --port 7681 --bash /bin/bash\n\
93
- ' > /start.sh && chmod +x /start.sh
94
-
95
- # Set default shell to bash
96
- SHELL ["/bin/bash", "-c"]
97
-
98
- # Start services
99
- CMD ["/start.sh"]
 
1
+ # FastAPI application on Hugging Face Spaces
2
+ # Docs: https://huggingface.co/docs/spaces/sdks/docker
3
 
4
+ FROM python:3.9
 
5
 
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ ENV PATH="/home/user/.local/bin:$PATH"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ WORKDIR /app
 
 
 
 
 
 
11
 
12
+ COPY --chown=user ./requirements.txt requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
 
14
 
15
+ COPY --chown=user . /app
 
 
 
 
 
 
16
 
17
+ EXPOSE 7860
 
 
 
 
 
 
 
 
 
18
 
19
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+
3
+ app = FastAPI()
4
+
5
+ @app.get("/")
6
+ def greet_json():
7
+ return {"Hello": "World!"}
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastapi
2
+ uvicorn[standard]