Spaces:
Sleeping
Sleeping
charbelmalo
commited on
Commit
·
783a18e
1
Parent(s):
7170a18
refactor Dockerfile to streamline setup and define entrypoint
Browse files- Dockerfile +12 -18
Dockerfile
CHANGED
@@ -1,36 +1,30 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.10-slim
|
3 |
|
|
|
|
|
|
|
4 |
# Create a user with a non-root UID
|
5 |
RUN useradd -m -u 1000 user
|
6 |
|
7 |
-
# Switch to the non-root user
|
8 |
-
USER user
|
9 |
-
|
10 |
# Set environment variables
|
11 |
ENV PATH="/home/user/.local/bin:$PATH"
|
12 |
ENV PYTHONDONTWRITEBYTECODE=1
|
13 |
ENV PYTHONUNBUFFERED=1
|
14 |
|
15 |
-
|
16 |
-
RUN apt-get update && apt-get install -y git
|
17 |
-
|
18 |
-
# Set the working directory
|
19 |
WORKDIR /app
|
|
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
-
|
24 |
-
# Copy and install dependencies
|
25 |
-
COPY --chown=user: /app/requirements.txt .
|
26 |
-
RUN pip install --no-cache-dir --upgrade pip
|
27 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
|
32 |
# Expose the port your app runs on
|
33 |
EXPOSE 8080
|
34 |
|
35 |
-
# Define the
|
36 |
-
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Install git and other necessary packages
|
5 |
+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
6 |
+
|
7 |
# Create a user with a non-root UID
|
8 |
RUN useradd -m -u 1000 user
|
9 |
|
|
|
|
|
|
|
10 |
# Set environment variables
|
11 |
ENV PATH="/home/user/.local/bin:$PATH"
|
12 |
ENV PYTHONDONTWRITEBYTECODE=1
|
13 |
ENV PYTHONUNBUFFERED=1
|
14 |
|
15 |
+
# Set the working directory and ensure it exists
|
|
|
|
|
|
|
16 |
WORKDIR /app
|
17 |
+
RUN chown user:user /app
|
18 |
|
19 |
+
# Copy the entrypoint script and set permissions
|
20 |
+
COPY entrypoint.sh /entrypoint.sh
|
21 |
+
RUN chmod +x /entrypoint.sh && chown user:user /entrypoint.sh
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
# Switch to the non-root user
|
24 |
+
USER user
|
25 |
|
26 |
# Expose the port your app runs on
|
27 |
EXPOSE 8080
|
28 |
|
29 |
+
# Define the entrypoint
|
30 |
+
ENTRYPOINT ["/entrypoint.sh"]
|