Memory / Dockerfile
Kaballas's picture
ee
15882cb
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile
FROM python:3.9
# Switch to root user to perform administrative tasks
USER root
# Install MariaDB server and client
RUN apt-get update \
&& apt-get install -y mariadb-server mariadb-client \
&& rm -rf /var/lib/apt/lists/*
# Create storage directory and link
RUN mkdir -p /data/storage \
&& ln -s /data/storage /storage
# Create user and set permissions
RUN useradd -m -u 1000 user \
&& chown -R user:user /data/storage
# Create /run/mysqld and set permissions AFTER user creation
RUN mkdir -p /run/mysqld && chown user:user /run/mysqld
# Set environment variables for storage and server port
ENV STORAGE_DIR="/data/storage"
ENV SERVER_PORT=7860
# Copy entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY --chown=user . /app
ENTRYPOINT ["/entrypoint.sh"]