molinari135
commited on
Update Dockerfile
Browse files- Dockerfile +24 -17
Dockerfile
CHANGED
@@ -1,35 +1,42 @@
|
|
1 |
FROM python:3.12-slim
|
2 |
|
|
|
3 |
RUN useradd -m -u 1000 user
|
4 |
|
|
|
5 |
USER user
|
6 |
|
|
|
7 |
ENV HOME=/home/user \
|
8 |
-
|
9 |
|
|
|
10 |
WORKDIR $HOME/app
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
|
21 |
-
|
22 |
-
COPY --chown=user
|
23 |
-
COPY --chown=user
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
COPY --chown=user models/svm.pkl $WORKDIR/models/
|
28 |
-
|
29 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
30 |
-
|
31 |
-
# RUN pip install --no-cache-dir .
|
32 |
|
|
|
33 |
EXPOSE 7860
|
34 |
|
|
|
35 |
CMD ["uvicorn", "product_return_prediction.api:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|
|
|
1 |
FROM python:3.12-slim
|
2 |
|
3 |
+
# Set up a new user with user ID 1000
|
4 |
RUN useradd -m -u 1000 user
|
5 |
|
6 |
+
# Switch to the "user" user
|
7 |
USER user
|
8 |
|
9 |
+
# Set environment variables for the user
|
10 |
ENV HOME=/home/user \
|
11 |
+
PATH=/home/user/.local/bin:$PATH
|
12 |
|
13 |
+
# Set the working directory to the user's home directory
|
14 |
WORKDIR $HOME/app
|
15 |
|
16 |
+
# Upgrade pip
|
17 |
+
RUN pip install --no-cache-dir --upgrade pip==23.3.1
|
18 |
|
19 |
+
# Install necessary build tools (if required for your dependencies)
|
20 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
21 |
+
build-essential && \
|
22 |
+
rm -rf /var/lib/apt/lists/*
|
23 |
|
24 |
+
# Copy the application code into the container at $HOME/app and set the ownership to the "user"
|
25 |
+
COPY --chown=user product_return_prediction $HOME/app/product_return_prediction
|
26 |
+
COPY --chown=user README.md $HOME/app/
|
27 |
+
COPY --chown=user requirements.txt $HOME/app/
|
28 |
+
COPY --chown=user pyproject.toml $HOME/app/
|
29 |
|
30 |
+
# Copy the external data and models, ensuring proper permissions
|
31 |
+
COPY --chown=user data/external/inventory.tsv $HOME/app/data/external/
|
32 |
+
COPY --chown=user models/scaler.pkl $HOME/app/models/
|
33 |
+
COPY --chown=user models/svm.pkl $HOME/app/models/
|
34 |
|
35 |
+
# Install Python dependencies
|
36 |
+
RUN pip install --no-cache-dir -r $HOME/app/requirements.txt
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
# Expose port 7860 for the app
|
39 |
EXPOSE 7860
|
40 |
|
41 |
+
# Set the command to run the FastAPI app with Uvicorn
|
42 |
CMD ["uvicorn", "product_return_prediction.api:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|