BinaryONe
commited on
Commit
·
8ba973d
1
Parent(s):
ee5b6f2
Nginx Changes-Over Alpine
Browse files- Dockerfile +9 -12
Dockerfile
CHANGED
|
@@ -4,30 +4,27 @@ FROM alpine:latest
|
|
| 4 |
RUN apk update && apk upgrade && \
|
| 5 |
apk add --no-cache nginx python3 py3-pip build-base libffi-dev openssl-dev shadow
|
| 6 |
|
| 7 |
-
|
| 8 |
# Create a group and user
|
| 9 |
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
| 10 |
|
| 11 |
-
# Tell docker that all future commands should run as the appuser user
|
| 12 |
-
USER appuser
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# Create a non-root user and group (Corrected and Simplified)
|
| 16 |
-
#RUN addgroup appgroup && adduser -G appgroup -s /bin/sh appuser
|
| 17 |
-
|
| 18 |
# Set working directory for the application
|
| 19 |
WORKDIR /app
|
| 20 |
|
|
|
|
| 21 |
# Copy only the necessary files first for better cache utilization
|
| 22 |
COPY requirements.txt /app/requirements.txt
|
| 23 |
|
| 24 |
-
# Install Python dependencies from the requirements file
|
| 25 |
-
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
| 26 |
-
|
| 27 |
# Copy the rest of the application code after installing dependencies for better cache
|
| 28 |
COPY . /app
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Set ownership of the app directory
|
| 33 |
RUN chown -R appuser:appgroup /app
|
|
|
|
| 4 |
RUN apk update && apk upgrade && \
|
| 5 |
apk add --no-cache nginx python3 py3-pip build-base libffi-dev openssl-dev shadow
|
| 6 |
|
|
|
|
| 7 |
# Create a group and user
|
| 8 |
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Set working directory for the application
|
| 11 |
WORKDIR /app
|
| 12 |
|
| 13 |
+
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
| 14 |
# Copy only the necessary files first for better cache utilization
|
| 15 |
COPY requirements.txt /app/requirements.txt
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
# Copy the rest of the application code after installing dependencies for better cache
|
| 18 |
COPY . /app
|
| 19 |
|
| 20 |
+
# Create a virtual environment within the container
|
| 21 |
+
RUN python3 -m venv /app/venv
|
| 22 |
+
|
| 23 |
+
# Activate the virtual environment (important!)
|
| 24 |
+
RUN source /app/venv/bin/activate
|
| 25 |
+
|
| 26 |
+
# Install Python dependencies from the requirements file within the virtual environment
|
| 27 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 28 |
|
| 29 |
# Set ownership of the app directory
|
| 30 |
RUN chown -R appuser:appgroup /app
|