added app, docker,req
Browse files- Dockerfile +19 -0
- app.py +5 -0
- requirements.txt +2 -0
Dockerfile
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.12
|
2 |
+
# Create a new user named 'user' with user ID 1000 and create their home directory
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
# Switch to the newly created user
|
5 |
+
USER user
|
6 |
+
# Add the user's local bin directory to the PATH
|
7 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
8 |
+
# Set the working directory in the container to /app
|
9 |
+
WORKDIR /app
|
10 |
+
# Copy the requirements.txt file from the host to the container
|
11 |
+
# The --chown=user ensures the copied file is owned by our 'user'
|
12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
13 |
+
# Install the Python dependencies listed in requirements.txt
|
14 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
15 |
+
# Copy the rest of the application code from the host to the container
|
16 |
+
# Again, ensure the copied files are owned by 'user'
|
17 |
+
COPY --chown=user . /app
|
18 |
+
# Specify the command to run when the container starts
|
19 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
app = FastAPI()
|
3 |
+
@app.get("/")
|
4 |
+
def greet_json():
|
5 |
+
return {"Hello": "World!"}
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
uvicorn[standard]
|