tel / Dockerfile
Mohammed Foud
all
35b6412
# Stage 1: Builder
FROM python:3-alpine AS builder
WORKDIR /app
# Create virtual environment and set environment variables
RUN python3 -m venv venv
ENV VIRTUAL_ENV=/app/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Copy all project files to the container
COPY . .
# Install dependencies from requirements.txt
RUN pip install -r requirements.txt
# Stage 2: Runner
FROM python:3-alpine AS runner
WORKDIR /app
# Copy virtual environment from the builder stage
COPY --from=builder /app/venv venv
# Copy all files again (including the ones that may have been modified in the builder stage)
COPY . .
# Set environment variables for the virtual environment
ENV VIRTUAL_ENV=/app/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Ensure that all files and folders have 777 permissions (read, write, and execute)
RUN chmod -R 777 /app
# Create a writable directory for Telethon session files
RUN mkdir -p /app/sessions && chmod -R 777 /app/sessions
# Set environment variable to specify session directory
ENV TELETHON_SESSION_DIR="/app/session"
# Expose the port where the Flask app will be running
EXPOSE 7860
# Run the script
CMD ["python3", "join11.py"]