Spaces:
Runtime error
Runtime error
Commit
·
864a2cd
1
Parent(s):
7e26d04
resolve merge errors
Browse files- Dockerfile +13 -2
- server.py +1 -2
Dockerfile
CHANGED
|
@@ -1,6 +1,15 @@
|
|
| 1 |
# Use the official Python image from the Docker Hub
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# install apt dependencies
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
|
@@ -46,13 +55,15 @@ RUN apt-get update && apt-get install -y \
|
|
| 46 |
WORKDIR /app
|
| 47 |
|
| 48 |
# Copy the requirements.txt file into the container at /app
|
| 49 |
-
COPY requirements.txt requirements.txt
|
| 50 |
|
| 51 |
# Install the dependencies
|
| 52 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 53 |
|
| 54 |
# Copy the rest of the application code into the container at /app
|
| 55 |
-
COPY . .
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# Set environment variables for Flask
|
| 58 |
ENV FLASK_APP=server.py
|
|
|
|
| 1 |
# Use the official Python image from the Docker Hub
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
| 4 |
+
RUN if id -u 1000 &> /dev/null; then \
|
| 5 |
+
uid=$(shuf -i 1001-65535 -n 1) \
|
| 6 |
+
&& useradd -m -u $uid user; \
|
| 7 |
+
else \
|
| 8 |
+
useradd -m -u 1000 user; \
|
| 9 |
+
fi
|
| 10 |
+
|
| 11 |
+
# Set the working directory inside the container
|
| 12 |
+
|
| 13 |
# install apt dependencies
|
| 14 |
RUN apt-get update && apt-get install -y \
|
| 15 |
build-essential \
|
|
|
|
| 55 |
WORKDIR /app
|
| 56 |
|
| 57 |
# Copy the requirements.txt file into the container at /app
|
| 58 |
+
COPY --chown=user requirements.txt requirements.txt
|
| 59 |
|
| 60 |
# Install the dependencies
|
| 61 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 62 |
|
| 63 |
# Copy the rest of the application code into the container at /app
|
| 64 |
+
COPY --chown=user . .
|
| 65 |
+
|
| 66 |
+
USER user
|
| 67 |
|
| 68 |
# Set environment variables for Flask
|
| 69 |
ENV FLASK_APP=server.py
|
server.py
CHANGED
|
@@ -6,8 +6,7 @@ from models.nutrition_model import NutritionModel
|
|
| 6 |
|
| 7 |
load_dotenv()
|
| 8 |
|
| 9 |
-
|
| 10 |
-
HOST = os.getenv("FLASK_RUN_HOST", "127.0.0.1")
|
| 11 |
FLASK_RUN_PORT = os.getenv("FLASK_RUN_PORT", 7860)
|
| 12 |
|
| 13 |
fitness_model = FitnessModel.load()
|
|
|
|
| 6 |
|
| 7 |
load_dotenv()
|
| 8 |
|
| 9 |
+
HOST = os.getenv("FLASK_RUN_HOST", "0.0.0.0")
|
|
|
|
| 10 |
FLASK_RUN_PORT = os.getenv("FLASK_RUN_PORT", 7860)
|
| 11 |
|
| 12 |
fitness_model = FitnessModel.load()
|