Skip to content

Commit ca178be

Browse files
committed
build: cache installed packages
1 parent c250048 commit ca178be

File tree

5 files changed

+323
-339
lines changed

5 files changed

+323
-339
lines changed

.github/workflows/deploy-image.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v3
13-
1412
- name: Log in to the Container registry
1513
uses: docker/login-action@v3
1614
with:
@@ -24,10 +22,14 @@ jobs:
2422
with:
2523
images: ${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}
2624

25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
2728
- name: Build and push Docker image
28-
uses: docker/build-push-action@v5
29+
uses: docker/build-push-action@v6
2930
with:
30-
context: .
3131
push: true
3232
tags: ${{ steps.meta.outputs.tags }}
3333
labels: ${{ steps.meta.outputs.labels }}
34+
cache-from: type=gha
35+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
FROM python:slim as base
1+
FROM python:slim AS base
22
WORKDIR /app
33
ENV PATH=.venv/bin:${PATH}
44

55

66
FROM base AS build
77
ENV PDM_CHECK_UPDATE=false
88

9-
RUN pip install pdm
10-
COPY pyproject.toml pdm.lock ./
11-
RUN pdm sync --prod --no-editable
9+
RUN pip install --no-cache-dir pdm
10+
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
11+
--mount=type=bind,source=pdm.lock,target=pdm.lock \
12+
--mount=type=cache,target=/root/.cache/pdm \
13+
pdm sync --prod --no-editable
1214

1315

1416
FROM base
1517

16-
COPY --from=build /app/.venv/ .venv
17-
COPY . .
18+
COPY --link --from=build /app/.venv/ .venv
19+
COPY --link . .
1820

1921
CMD nb orm upgrade && nb run

0 commit comments

Comments
 (0)