Spaces:
Running
Running
FROM alpine:latest | |
# Install system dependencies | |
RUN apk update && apk upgrade && \ | |
apk add --no-cache nginx python3 py3-pip build-base libffi-dev openssl-dev | |
# Create and use a non-root user | |
RUN useradd -ms /bin/bash appuser | |
# Create a non-root user and group | |
RUN addgroup appgroup && adduser -G appgroup appuser | |
# Set working directory for the application | |
WORKDIR /app | |
# Copy only the necessary files first for better cache utilization | |
COPY requirements.txt /app/requirements.txt | |
# Install system dependencies and clean up in a single RUN step to reduce layers | |
#RUN apt-get update -y && apt-get upgrade -y \ | |
# && apt-get install -y \ | |
# && apt-get clean \ | |
# && rm -rf /var/lib/apt/lists/* | |
# Install Python dependencies from the requirements file | |
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt | |
# Copy the rest of the application code after installing dependencies for better cache | |
COPY . /app | |
COPY nginx.conf /etc/nginx/conf.d/default.conf | |
WORKDIR /app | |
RUN chown -R appuser:appgroup /app | |
USER appuser | |
EXPOSE 7860 | |
# Start Nginx and the AIOHTTP app | |
CMD ["sh", "-c", "python -u -m FileStream & nginx -g 'daemon off;'"] | |
# Set ownership and permissions for the app directory | |
#RUN chown -R admin:admin /app && chmod -R 777 /app | |
# Switch to the non-root user for better security | |
#USER admin | |
# Expose the port the application will run on | |
#EXPOSE 7860 | |
# Command to run the application | |
#CMD ["python", "-u", "-m", "FileStream"] | |