teleapi / Dockerfile
BinaryONe
Nginx Changes-Over Alpine
a11228a
raw
history blame
1.69 kB
FROM alpine:latest
# Install system dependencies
RUN apk update && apk upgrade && \
apk add --no-cache nginx python3 python3-dev py3-pip build-base libffi-dev openssl-dev shadow gcc musl-dev ca-certificates
# Create a group and user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Set working directory
WORKDIR /app
# Copy requirements and install in ONE combined RUN command
COPY requirements.txt /app/
RUN python3 -m venv /app/venv && \
/app/venv/bin/pip install --no-cache-dir --upgrade pip && \
/app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
/app/venv/bin/pip list # Verify installation WITHIN THE SAME RUN COMMAND
# Copy the rest of the application code
COPY . /app
# Copy Nginx config
COPY default_conf.conf /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
#RUN touch /var/lib/nginx/logs/error.log && \
# chmod 777 /var/lib/nginx/logs/error.log
# Create necessary directories and set correct permissions
RUN mkdir -p /var/www/html /var/log/nginx /run/nginx && \
chown -R nginx:nginx /var/lib/nginx /var/log/nginx /run/nginx && \
# Note the /var/lib/nginx here
chown -R appuser:nginx /app /var/www/html /var/log/nginx
# Remove the user directive from the main nginx.conf
#RUN sed -i '/^user /d' /etc/nginx/nginx.conf
# Print the configuration files to the console (NEW)
RUN cat /etc/nginx/nginx.conf && echo "--------------------" && cat /etc/nginx/conf.d/default.conf
# Switch to non-root user
USER appuser
EXPOSE 7860
# Start Nginx and your application (using exec and the correct Python path)
CMD ["sh", "-c", "exec /app/venv/bin/python -u -m FileStream & nginx -g 'daemon off;'"]