Skip to content

Commit

Permalink
Feature/docker deploy push (#887)
Browse files Browse the repository at this point in the history
* build: add Dockerfile for base image with common dependencies and stages for different functionalities

* build: add Dockerfile for base image with common dependencies and stages for different functionalities

---------

Co-authored-by: 홍승우 <martin@hongseung-uui-MacBookAir.local>
  • Loading branch information
hongsw and 홍승우 authored Oct 25, 2024
1 parent 3f98336 commit d6dfe31
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 65 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ jobs:
uses: docker/build-push-action@v6.9.0
with:
context: .
file: ./docker/base/Dockerfile
file: Dockerfile.base
push: true
# push: ${{ github.event_name != 'pull_request' && matrix.variant != 'test' }}
tags: ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}}
tags: ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TARGET_STAGE=${{ matrix.variant }}
- name: Tag and push 'all' for production
run: |
docker pull ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}}
docker tag ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}} ${{ env.DOCKER_REPO }}:latest
docker push ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}}
docker push ${{ env.DOCKER_REPO }}:latest
docker pull ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }}
docker tag ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }} ${{ env.DOCKER_REPO }}:${{matrix.variant}}-latest
docker push ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }}
docker push ${{ env.DOCKER_REPO }}:${{matrix.variant}}-latest
# - name: Update Docker Hub description
# uses: peter-evans/dockerhub-description@v3
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/gpu-docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ jobs:
uses: docker/build-push-action@v6.9.0
with:
context: .
file: ./docker/gpu/Dockerfile
file: ./Dockerfile.gpu
push: true
# push: ${{ github.event_name != 'pull_request' && matrix.variant != 'test' }}
tags: ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}}
tags: ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TARGET_STAGE=${{ matrix.variant }}
- name: Tag and push 'all' for production
run: |
docker pull ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}}
docker tag ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}} ${{ env.DOCKER_REPO }}:latest
docker push ${{ env.DOCKER_REPO }}:${{ env.VERSION }}-${{matrix.variant}}
docker push ${{ env.DOCKER_REPO }}:latest
docker pull ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }}
docker tag ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }} ${{ env.DOCKER_REPO }}:${{matrix.variant}}-latest
docker push ${{ env.DOCKER_REPO }}:${{matrix.variant}}-${{ env.VERSION }}
docker push ${{ env.DOCKER_REPO }}:${{matrix.variant}}-latest
# - name: Update Docker Hub description
# uses: peter-evans/dockerhub-description@v3
Expand Down
71 changes: 71 additions & 0 deletions Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Base stage: Install common dependencies
FROM python:3.10-slim AS base

# Set working directory and environment variables
WORKDIR /usr/src/app
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1

# Copy only requirements files first to leverage Docker cache
COPY pyproject.toml ./

# Install system and Python dependencies in a single layer
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
gcc \
libssl-dev && \
pip install --upgrade pip setuptools setuptools-scm && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /root/.cache/pip/*

# Copy project files
COPY . .

# Install base project
RUN pip install -e ./ && \
rm -rf /root/.cache/pip/*

# Ko stage with minimal dependencies
FROM base AS ko
RUN pip install --no-cache-dir "AutoRAG[ko]" && \
rm -rf /root/.cache/pip/*
ENTRYPOINT ["python", "-m", "autorag.cli"]

# Dev stage with all development tools
FROM base AS dev
RUN pip install --no-cache-dir \
-r ./tests/requirements.txt \
-r ./docs/requirements.txt \
"AutoRAG[dev]" && \
rm -rf /root/.cache/pip/*
ENTRYPOINT ["python", "-m", "autorag.cli"]

# Ja stage with Japanese support
FROM base AS ja
RUN pip install --no-cache-dir "AutoRAG[ja]" && \
rm -rf /root/.cache/pip/*
ENTRYPOINT ["python", "-m", "autorag.cli"]

# API stage with minimal footprint
FROM base AS api
RUN rm -rf \
./sample_dataset \
./tests \
./docs \
/root/.cache/pip/*
ENTRYPOINT ["python", "-m", "autorag.cli"]

# Parsing stage with OCR support
FROM base AS parsing
RUN apt-get update && \
apt-get install -y --no-install-recommends \
poppler-utils \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-kor && \
pip install --no-cache-dir "AutoRAG[parse]" && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /root/.cache/pip/*
ENTRYPOINT ["python", "-m", "autorag.cli"]
File renamed without changes.
53 changes: 0 additions & 53 deletions docker/base/Dockerfile

This file was deleted.

0 comments on commit d6dfe31

Please sign in to comment.