Skip to content

Commit

Permalink
Refactor Dockerfiles for serverless functions
Browse files Browse the repository at this point in the history
  • Loading branch information
VikramxD committed Oct 24, 2024
1 parent fff88d8 commit 1a96b04
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 42 deletions.
28 changes: 17 additions & 11 deletions serverless/image-to-video/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
PYTHONPATH=/app \
PATH="/usr/local/bin:$PATH"

# Set up working directory
WORKDIR /app
Expand All @@ -21,29 +22,34 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Create symbolic link for python
RUN ln -sf /usr/bin/python3.11 /usr/bin/python
# Create symbolic link for python and pip
RUN ln -sf /usr/bin/python3.11 /usr/bin/python && \
ln -sf /usr/bin/pip3 /usr/bin/pip

# Create user and set permissions
RUN useradd -m -u 1000 user && \
chown -R user:user /app
USER user

# Install base packages as root
RUN pip install --no-cache-dir -U pip setuptools wheel

# Copy all required files and directories
COPY --chown=user:user api/ /app/api/
COPY --chown=user:user scripts/ /app/scripts/
COPY --chown=user:user configs/ /app/configs/
COPY --chown=user:user setup.py /app/


# Install Python dependencies
RUN pip install --no-cache-dir -U pip setuptools wheel && \
pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod && \
# Install Python dependencies as root
RUN pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod==1.3.3 && \
pip install --no-cache-dir -e .

# Copy the handler (change this for each service)
# Switch to user after installations
USER user

COPY --chown=user:user serverless/image-to-video/run_image-to-video.py .

# Use full path to python
# Add verification step
RUN python -c "import runpod; print(f'RunPod version: {runpod.__version__}')"

CMD ["/usr/bin/python3.11", "run_image-to-video.py"]
27 changes: 18 additions & 9 deletions serverless/inpainting/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
PYTHONPATH=/app \
PATH="/usr/local/bin:$PATH"

# Set up working directory
WORKDIR /app
Expand All @@ -21,26 +22,34 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Create symbolic link for python
RUN ln -sf /usr/bin/python3.11 /usr/bin/python
# Create symbolic link for python and pip
RUN ln -sf /usr/bin/python3.11 /usr/bin/python && \
ln -sf /usr/bin/pip3 /usr/bin/pip

# Create user and set permissions
RUN useradd -m -u 1000 user && \
chown -R user:user /app
USER user

# Install base packages as root
RUN pip install --no-cache-dir -U pip setuptools wheel

# Copy all required files and directories
COPY --chown=user:user api/ /app/api/
COPY --chown=user:user scripts/ /app/scripts/
COPY --chown=user:user configs/ /app/configs/
COPY --chown=user:user setup.py /app/


# Install Python dependencies
RUN pip install --no-cache-dir -U pip setuptools wheel && \
pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod && \
# Install Python dependencies as root
RUN pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod==1.3.3 && \
pip install --no-cache-dir -e .

# Switch to user after installations
USER user

COPY --chown=user:user serverless/inpainting/run_inpainting.py .

# Add verification step
RUN python -c "import runpod; print(f'RunPod version: {runpod.__version__}')"

CMD ["/usr/bin/python3.11", "run_inpainting.py"]
28 changes: 17 additions & 11 deletions serverless/outpainting/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
PYTHONPATH=/app \
PATH="/usr/local/bin:$PATH"

# Set up working directory
WORKDIR /app
Expand All @@ -21,29 +22,34 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Create symbolic link for python
RUN ln -sf /usr/bin/python3.11 /usr/bin/python
# Create symbolic link for python and pip
RUN ln -sf /usr/bin/python3.11 /usr/bin/python && \
ln -sf /usr/bin/pip3 /usr/bin/pip

# Create user and set permissions
RUN useradd -m -u 1000 user && \
chown -R user:user /app
USER user

# Install base packages as root
RUN pip install --no-cache-dir -U pip setuptools wheel

# Copy all required files and directories
COPY --chown=user:user api/ /app/api/
COPY --chown=user:user scripts/ /app/scripts/
COPY --chown=user:user configs/ /app/configs/
COPY --chown=user:user setup.py /app/


# Install Python dependencies
RUN pip install --no-cache-dir -U pip setuptools wheel && \
pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod && \
# Install Python dependencies as root
RUN pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod==1.3.3 && \
pip install --no-cache-dir -e .

# Copy the handler (change this for each service)
# Switch to user after installations
USER user

COPY --chown=user:user serverless/outpainting/run_outpainting.py .

# Use full path to python
# Add verification step
RUN python -c "import runpod; print(f'RunPod version: {runpod.__version__}')"

CMD ["/usr/bin/python3.11", "run_outpainting.py"]
28 changes: 17 additions & 11 deletions serverless/text-to-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
PYTHONPATH=/app \
PATH="/usr/local/bin:$PATH"

# Set up working directory
WORKDIR /app
Expand All @@ -21,29 +22,34 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Create symbolic link for python
RUN ln -sf /usr/bin/python3.11 /usr/bin/python
# Create symbolic link for python and pip
RUN ln -sf /usr/bin/python3.11 /usr/bin/python && \
ln -sf /usr/bin/pip3 /usr/bin/pip

# Create user and set permissions
RUN useradd -m -u 1000 user && \
chown -R user:user /app
USER user

# Install base packages as root
RUN pip install --no-cache-dir -U pip setuptools wheel

# Copy all required files and directories
COPY --chown=user:user api/ /app/api/
COPY --chown=user:user scripts/ /app/scripts/
COPY --chown=user:user configs/ /app/configs/
COPY --chown=user:user setup.py /app/


# Install Python dependencies
RUN pip install --no-cache-dir -U pip setuptools wheel && \
pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod && \
# Install Python dependencies as root
RUN pip install --no-cache-dir -r api/requirements.txt && \
pip install --no-cache-dir runpod==1.3.3 && \
pip install --no-cache-dir -e .

# Copy the handler (change this for each service)
# Switch to user after installations
USER user

COPY --chown=user:user serverless/text-to-image/run_text-to-image.py .

# Use full path to python
# Add verification step
RUN python -c "import runpod; print(f'RunPod version: {runpod.__version__}')"

CMD ["/usr/bin/python3.11", "run_text-to-image.py"]

0 comments on commit 1a96b04

Please sign in to comment.