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 8c11dc5 commit 38c2f87
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 64 deletions.
18 changes: 2 additions & 16 deletions serverless/image-to-video/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app

# Set up working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
Expand All @@ -22,30 +19,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

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

# Switch to user
USER user

# Create and activate virtual environment
RUN python3.11 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"

# Copy necessary files maintaining structure
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/
COPY --chown=user:user . .

# Install dependencies in venv
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 && \
pip install --no-cache-dir -e .

# Copy the service file
COPY --chown=user:user serverless/image-to-video/run_image-to-video.py .

CMD ["python", "run_image-to-video.py"]
CMD ["python", "serverless/image-to-video/run_image-to-video.py"]
18 changes: 2 additions & 16 deletions serverless/inpainting/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app

# Set up working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
Expand All @@ -22,30 +19,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

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

# Switch to user
USER user

# Create and activate virtual environment
RUN python3.11 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"

# Copy necessary files maintaining structure
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/
COPY --chown=user:user . .

# Install dependencies in venv
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 && \
pip install --no-cache-dir -e .

# Copy the service file
COPY --chown=user:user serverless/inpainting/run_inpainting.py .

CMD ["python", "run_inpainting.py"]
CMD ["python", "serverless/inpainting/run_inpainting.py"]
18 changes: 2 additions & 16 deletions serverless/outpainting/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app

# Set up working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
Expand All @@ -22,30 +19,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

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

# Switch to user
USER user

# Create and activate virtual environment
RUN python3.11 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"

# Copy necessary files maintaining structure
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/
COPY --chown=user:user . .

# Install dependencies in venv
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 && \
pip install --no-cache-dir -e .

# Copy the service file
COPY --chown=user:user serverless/outpainting/run_outpainting.py .

CMD ["python", "run_outpainting.py"]
CMD ["python", "serverless/outpainting/run_outpainting.py"]
18 changes: 2 additions & 16 deletions serverless/text-to-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app

# Set up working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
Expand All @@ -22,30 +19,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*

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

# Switch to user
USER user

# Create and activate virtual environment
RUN python3.11 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"

# Copy necessary files maintaining structure
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/
COPY --chown=user:user . .

# Install dependencies in venv
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 && \
pip install --no-cache-dir -e .

# Copy the service file
COPY --chown=user:user serverless/text-to-image/run_text-to-image.py .

CMD ["python", "run_text-to-image.py"]
CMD ["python", "serverless/text-to-image/run_text-to-image.py"]

0 comments on commit 38c2f87

Please sign in to comment.