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"]
# =====================================================================

View File

@@ -1,39 +0,0 @@
@echo off
echo Welcome to ALwrity Installer
echo ============================
echo.
:: Check if Python 3.11 is installed
python --version 2>nul | findstr /i "3.11" >nul
if errorlevel 1 (
echo Python 3.11 is not installed or not in PATH
echo Please install Python 3.11 from https://www.python.org/downloads/release/python-3116/
echo Make sure to check "Add Python 3.11 to PATH" during installation
echo.
echo Press any key to open the download page...
pause >nul
start https://www.python.org/downloads/release/python-3116/
exit /b 1
)
:: Create virtual environment if it doesn't exist
if not exist "venv" (
echo Creating virtual environment...
python -m venv venv
)
:: Activate virtual environment and install requirements
echo Activating virtual environment...
call venv\Scripts\activate.bat
echo Upgrading pip...
python -m pip install --upgrade pip
echo Installing ALwrity...
python setup.py install
echo.
echo Installation complete!
echo To start ALwrity, open a new command prompt and type: alwrity
echo.
pause