Skip to content

Commit b54c191

Browse files
authored
Merge pull request #170 from sparkgeo/143-build-redundancy
fix(#143): reduce redundant work in container image builds
2 parents 4dd98fe + 42a699f commit b54c191

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
**/*.egg-info
44
**/__pycache__
55
**/cdk.out
6-
**/.venv
6+
**/*.egg-info
77

8+
packages/stac-index/tests
9+
10+
**/.venv
811
**/.env
912
**/.idea
1013
**/.vscode

docker/api/Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@ ENV UV_LINK_MODE=copy \
1515
### End build prep -- this is where your app Dockerfile should start.
1616

1717
WORKDIR /src
18-
COPY ./ /src
18+
COPY pyproject.toml .
19+
COPY uv.lock .
1920

21+
# File is required to successfully parse root package.toml, even though not installed.
22+
COPY packages/stac-index/pyproject.toml ./packages/stac-index/
2023

21-
RUN uv sync \
22-
--directory=/src \
23-
--locked \
24-
--no-dev \
25-
--no-install-project
26-
24+
# Install dependencies.
2725
RUN uv sync \
2826
--extra server \
2927
--locked \
3028
--no-dev \
31-
--no-editable
32-
29+
--no-install-workspace
3330

3431
# ##########################################################################
3532

docker/indexer/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@ ENV UV_LINK_MODE=copy \
1313
UV_PROJECT_ENVIRONMENT=/opt/app
1414

1515
### End build prep -- this is where your app Dockerfile should start.
16-
COPY ./ /src
16+
1717
WORKDIR /src
18+
COPY pyproject.toml .
19+
COPY uv.lock .
20+
21+
# Files are required to successfully parse package.toml, even though the project is not installed at this stage.
22+
COPY packages/stac-index/pyproject.toml ./packages/stac-index/
23+
COPY packages/stac-index/README.md ./packages/stac-index/
1824

25+
# Install dependencies first, then application code, as dependencies change less frequently.
1926
RUN uv sync \
2027
--package=stac-index \
21-
--directory=/src \
2228
--locked \
2329
--no-dev \
2430
--no-install-project
2531

32+
# Copy and install application code.
33+
COPY packages/stac-index/* ./packages/stac-index/
2634
RUN uv sync \
2735
--package=stac-index \
28-
--directory=/src \
2936
--locked \
3037
--no-dev \
3138
--no-editable

iac/api/Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@ ENV UV_LINK_MODE=copy \
1515
### End build prep -- this is where your app Dockerfile should start.
1616

1717
WORKDIR /src
18-
COPY ./ /src
18+
COPY pyproject.toml .
19+
COPY uv.lock .
1920

21+
# File is required to successfully parse root package.toml, even though not installed.
22+
COPY packages/stac-index/pyproject.toml ./packages/stac-index/
2023

21-
RUN uv sync \
22-
--directory=/src \
23-
--locked \
24-
--no-dev \
25-
--no-install-project
26-
24+
# Install dependencies.
2725
RUN uv sync \
2826
--extra lambda \
2927
--locked \
3028
--no-dev \
31-
--no-editable
32-
29+
--no-install-workspace
3330

3431
# ##########################################################################
3532

iac/indexer/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@ ENV UV_LINK_MODE=copy \
1313
UV_PROJECT_ENVIRONMENT=/opt/app
1414

1515
### End build prep -- this is where your app Dockerfile should start.
16-
COPY ./ /src
16+
1717
WORKDIR /src
18+
COPY pyproject.toml .
19+
COPY uv.lock .
20+
21+
# Files are required to successfully parse package.toml, even though the project is not installed at this stage.
22+
COPY packages/stac-index/pyproject.toml ./packages/stac-index/
23+
COPY packages/stac-index/README.md ./packages/stac-index/
1824

25+
# Install dependencies first, then application code, as dependencies change less frequently.
1926
RUN uv sync \
2027
--package=stac-index \
21-
--directory=/src \
2228
--locked \
2329
--no-dev \
2430
--no-install-project
2531

32+
# Copy and install application code.
33+
COPY packages/stac-index/* ./packages/stac-index/
2634
RUN uv sync \
2735
--package=stac-index \
28-
--directory=/src \
2936
--locked \
3037
--no-dev \
3138
--no-editable

0 commit comments

Comments
 (0)