Spaces:
Runtime error
Runtime error
Commit ·
900de1b
1
Parent(s): cde23de
Update Dockerfile
Browse files- Dockerfile +26 -14
Dockerfile
CHANGED
|
@@ -1,30 +1,42 @@
|
|
| 1 |
-
#
|
| 2 |
FROM python:3.8-slim-buster
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Install necessary packages
|
| 11 |
-
RUN apt-get update \
|
| 12 |
-
&& apt-get install -y nginx \
|
| 13 |
-
&& apt-get clean
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
# Copy the current directory contents into the container at /app
|
| 16 |
-
COPY . /app
|
| 17 |
|
| 18 |
# Install any needed packages specified in requirements.txt
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
# Setup NGINX
|
| 22 |
-
RUN rm /etc/nginx/sites-enabled/default
|
| 23 |
-
COPY nginx.conf /etc/nginx/sites-available/
|
| 24 |
-
RUN ln -s /etc/nginx/sites-available/nginx.conf /etc/nginx/sites-enabled/
|
| 25 |
|
| 26 |
# Expose port for the app
|
| 27 |
EXPOSE 7680
|
| 28 |
|
| 29 |
# Start the application
|
| 30 |
-
CMD service nginx start && python app.py
|
|
|
|
| 1 |
+
# Set up the environment with Python
|
| 2 |
FROM python:3.8-slim-buster
|
| 3 |
|
| 4 |
+
# Set up a new user named "user" with user ID 1000
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
|
| 7 |
+
# Switch to the "user" user
|
| 8 |
+
USER user
|
| 9 |
+
|
| 10 |
+
# Set home to the user's home directory
|
| 11 |
+
ENV HOME=/home/user \
|
| 12 |
+
PATH=/home/user/.local/bin:$PATH \
|
| 13 |
+
API_ENDPOINT=$API_ENDPOINT \
|
| 14 |
+
WORKERS=$WORKERS
|
| 15 |
+
|
| 16 |
+
# Set the working directory to the user's home directory
|
| 17 |
+
WORKDIR $HOME/app
|
| 18 |
|
| 19 |
# Install necessary packages
|
| 20 |
+
RUN sudo apt-get update \
|
| 21 |
+
&& sudo apt-get install -y nginx \
|
| 22 |
+
&& sudo apt-get clean
|
| 23 |
+
|
| 24 |
+
# Upgrade pip
|
| 25 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 26 |
|
| 27 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 28 |
+
COPY --chown=user . $HOME/app
|
| 29 |
|
| 30 |
# Install any needed packages specified in requirements.txt
|
| 31 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 32 |
|
| 33 |
# Setup NGINX
|
| 34 |
+
RUN sudo rm /etc/nginx/sites-enabled/default
|
| 35 |
+
COPY --chown=user nginx.conf /etc/nginx/sites-available/
|
| 36 |
+
RUN sudo ln -s /etc/nginx/sites-available/nginx.conf /etc/nginx/sites-enabled/
|
| 37 |
|
| 38 |
# Expose port for the app
|
| 39 |
EXPOSE 7680
|
| 40 |
|
| 41 |
# Start the application
|
| 42 |
+
CMD service nginx start && python app.py
|