Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +6 -32
Dockerfile
CHANGED
@@ -1,42 +1,16 @@
|
|
1 |
-
|
2 |
-
FROM python:3.9 AS builder
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
apt-get install -y git
|
7 |
|
8 |
-
# Set working directory
|
9 |
WORKDIR /code
|
10 |
|
11 |
-
# Copy requirements file
|
12 |
COPY ./requirements.txt /code/requirements.txt
|
13 |
|
14 |
-
|
15 |
-
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
16 |
-
|
17 |
-
# Stage 2: Runtime stage
|
18 |
-
FROM python:3.9
|
19 |
-
|
20 |
-
# Set working directory
|
21 |
-
WORKDIR /code
|
22 |
-
|
23 |
-
# Copy from the builder stage
|
24 |
-
COPY --from=builder /code /code
|
25 |
-
|
26 |
-
# Set environment variable for GitHub token (replace with your actual token)
|
27 |
-
ARG gh_token
|
28 |
-
ENV gh_token=${gh_token}
|
29 |
-
|
30 |
-
# Clone your repository using the token
|
31 |
-
RUN url_with_token="https://$gh_token@github.com/yourusername/your-repo.git" && \
|
32 |
-
git clone $url_with_token /code
|
33 |
-
|
34 |
-
# Set the working directory to your cloned repository
|
35 |
-
WORKDIR /code
|
36 |
|
37 |
-
# Install remaining dependencies (if any)
|
38 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
39 |
|
|
|
40 |
|
41 |
-
|
42 |
-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
FROM python:3.9
|
|
|
2 |
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
USER user
|
|
|
5 |
|
|
|
6 |
WORKDIR /code
|
7 |
|
|
|
8 |
COPY ./requirements.txt /code/requirements.txt
|
9 |
|
10 |
+
RUN chown -R user:user /code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
|
|
12 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
13 |
|
14 |
+
COPY --chown=user:user . /code
|
15 |
|
16 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|