# Use an official Python runtime as a parent image
#FROM python:3.10-slim-bullseye
FROM python:3.11-alpine

LABEL name="Gallery-Archivist" \
    maintainer="Aroy-Art" \
    description="All-in-one personal social-media/art site archiving container" \
    homepage="https://git.aroy-art.com/Aroy/Gallery-Archivist" \
    documentation=""
 
ENV PYTHONUNBUFFERED 1

# Install apk dependencies
RUN apk update && \
    apk add curl rustup cargo make gcc g++ automake subversion python3-dev

# Create non-privileged user
ARG USER_ID
RUN adduser -D -u $USER_ID archivist
#RUN addgroup -S $GROUP \
#    && adduser --system --create-home --gid $GROUP --groups audio,video $USER

# Download latest yt-dlp version and make executable
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && \
    chmod a+rx /usr/local/bin/yt-dlp
 
# Install latest stable gallery-dl
RUN pip install -U gallery-dl

COPY ./requirements.txt /app/

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
#COPY . /app

# Install any needed packages specified in requirements.txt
#RUN export PYTHONPATH=/usr/bin/python && pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Make port 8000 available to the world outside this container
EXPOSE 8000

USER archivist

# Define environment variable
#ENV DJANGO_SETTINGS_MODULE=mysite.settings.production

# Run the command to start Django
#CMD ["python", "archivist/manage.py", "runserver", "0.0.0.0:8000"]