Getting started Guides and Dockerfile, setup.py, and install.bat

This commit is contained in:
ي
2025-04-23 13:25:33 +00:00
parent f48d58c7df
commit 20b4782951
2 changed files with 30 additions and 58 deletions

View File

@@ -1,23 +1,18 @@
# =====================================================================
# ALwrity Automated Dockerfile - Zero Manual Steps for End Users
# ALwrity Automated Dockerfile - Best Practices & Full Functionality
# =====================================================================
# This Dockerfile will automatically:
# 1. Use Python 3.11
# 2. Install all system dependencies (build tools, Rust, etc.)
# 3. Clone the latest ALwrity code from GitHub
# 4. Install Python dependencies
# 5. Set up a non-root user
# 6. Expose Streamlit port and run the app
# This Dockerfile is designed for cache efficiency, security, and ease of use.
# It uses multi-stage builds for smaller images and leverages Docker layer caching.
# =====================================================================
# 1. Use official Python 3.11 image
FROM python:3.11-slim as base
# 1. Use official Python 3.11 image (builder stage)
FROM python:3.11-slim AS builder
# 2. Set environment variables for Python
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# 3. Install system dependencies
# 3. Install build dependencies first (for cache efficiency)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
@@ -25,7 +20,6 @@ RUN apt-get update && \
git \
curl \
wget \
nano \
libffi-dev \
libssl-dev \
rustc \
@@ -35,24 +29,41 @@ RUN apt-get update && \
# 4. Set work directory
WORKDIR /app
# 5. Clone the latest ALwrity code from GitHub
RUN git clone https://github.com/AJaySi/AI-Writer.git .
# 5. Copy only requirements.txt first (for better caching)
COPY ../../requirements.txt ./
# 6. Install Python dependencies
# 6. Install Python dependencies in builder
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 7. Create a non-root user for security
# 7. Clone the latest ALwrity code from GitHub (after dependencies for cache efficiency)
RUN git clone https://github.com/AJaySi/AI-Writer.git .
# 8. Copy only necessary files to the final image (runtime stage)
FROM python:3.11-slim AS runtime
# 9. Set environment variables for Python
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# 10. Create a non-root user for security
RUN useradd -m alwrityuser
USER alwrityuser
# 8. Expose Streamlit's default port
# 11. Set work directory
WORKDIR /app
# 12. Copy installed packages and app from builder
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /app /app
# 13. Expose Streamlit's default port
EXPOSE 8501
# 9. Set environment variable for Streamlit (optional: disables telemetry)
# 14. Set environment variable for Streamlit (optional: disables telemetry)
ENV STREAMLIT_TELEMETRY=0
# 10. Default command: run ALwrity with Streamlit
# 15. Default command: run ALwrity with Streamlit
CMD ["streamlit", "run", "alwrity.py", "--server.port=8501", "--server.address=0.0.0.0"]
# =====================================================================