improved dockerfile
Browse files- Dockerfile +25 -6
Dockerfile
CHANGED
@@ -1,17 +1,34 @@
|
|
1 |
-
#
|
2 |
-
FROM
|
3 |
|
|
|
4 |
RUN useradd -m -u 1000 user
|
5 |
USER user
|
6 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
7 |
|
|
|
8 |
WORKDIR /app
|
9 |
|
|
|
10 |
COPY --chown=user ./requirements.txt requirements.txt
|
11 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
12 |
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Copy the application code
|
17 |
COPY --chown=user . /app
|
@@ -19,7 +36,9 @@ COPY --chown=user . /app
|
|
19 |
# Expose the port for Streamlit
|
20 |
EXPOSE 7860
|
21 |
|
|
|
22 |
COPY --chown=user ./startup.sh /app/startup.sh
|
23 |
RUN chmod +x /app/startup.sh
|
24 |
|
25 |
-
|
|
|
|
1 |
+
# Stage 1: Build stage with Python and pip
|
2 |
+
FROM python:3.9 AS builder
|
3 |
|
4 |
+
# Create a non-root user
|
5 |
RUN useradd -m -u 1000 user
|
6 |
USER user
|
|
|
7 |
|
8 |
+
# Set the working directory
|
9 |
WORKDIR /app
|
10 |
|
11 |
+
# Copy requirements file and install dependencies
|
12 |
COPY --chown=user ./requirements.txt requirements.txt
|
13 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
14 |
|
15 |
+
|
16 |
+
# Stage 2: Runtime stage with Ollama
|
17 |
+
FROM ollama/ollama:latest
|
18 |
+
|
19 |
+
# Create the same non-root user for consistency
|
20 |
+
RUN useradd -m -u 1000 user
|
21 |
+
USER user
|
22 |
+
|
23 |
+
# Set the environment PATH
|
24 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
25 |
+
|
26 |
+
# Set the working directory
|
27 |
+
WORKDIR /app
|
28 |
+
|
29 |
+
# Copy Python dependencies from the build stage
|
30 |
+
COPY --from=builder /usr/local/lib/python3.9 /usr/local/lib/python3.9
|
31 |
+
COPY --from=builder /usr/local/bin /usr/local/bin
|
32 |
|
33 |
# Copy the application code
|
34 |
COPY --chown=user . /app
|
|
|
36 |
# Expose the port for Streamlit
|
37 |
EXPOSE 7860
|
38 |
|
39 |
+
# Add and set up the startup script
|
40 |
COPY --chown=user ./startup.sh /app/startup.sh
|
41 |
RUN chmod +x /app/startup.sh
|
42 |
|
43 |
+
# Command to run the application
|
44 |
+
CMD ["/app/startup.sh"]
|