Skip to content

Commit

Permalink
Merge pull request #357 from dtrifiro/use-build-cache
Browse files Browse the repository at this point in the history
Dockerfile: use build cache
  • Loading branch information
evaline-ju committed May 15, 2024
2 parents a5bf25e + 1b41528 commit 769812f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
name: Build Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Setup tox
run: |
pip install -U pip wheel
pip install tox
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
run: |
docker build -t caikit-nlp:latest .
uses: docker/build-push-action@v5
with:
context: .
tags: "caikit-nlp:latest"
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ COPY pyproject.toml .
COPY tox.ini .
COPY caikit_nlp caikit_nlp
# .git is required for setuptools-scm get the version
RUN --mount=source=.git,target=.git,type=bind tox -e build
RUN --mount=source=.git,target=.git,type=bind \
--mount=type=cache,target=/root/.cache/pip \
tox -e build


FROM base as deploy
Expand All @@ -26,7 +28,9 @@ ENV VIRTUAL_ENV=/opt/caikit
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY --from=builder /build/dist/caikit_nlp*.whl /tmp/
RUN pip install --no-cache /tmp/caikit_nlp*.whl && rm /tmp/caikit_nlp*.whl
RUN --mount=type=cache,target=/root/.cache/pip \
pip install /tmp/caikit_nlp*.whl && \
rm /tmp/caikit_nlp*.whl

COPY LICENSE /opt/caikit/
COPY README.md /opt/caikit/
Expand Down

0 comments on commit 769812f

Please sign in to comment.