Skip to content

Commit adf8bf3

Browse files
committed
Updated docker build files
1 parent 40cf338 commit adf8bf3

File tree

8 files changed

+44
-52
lines changed

8 files changed

+44
-52
lines changed

.github/workflows/build-legacy-tileserver.yaml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,31 @@ on:
55
branches: ["main"]
66
paths:
77
- services/legacy-tileserver/**
8+
- py-modules/tileserver-utils/**
89
tags:
910
- legacy-tileserver-v[0-9]+.[0-9]+.[0-9]+ # Semver Release (non-prerelease)
1011
- legacy-tileserver-v[0-9]+.[0-9]+.[0-9]+-** # Semver release (prerelease)
1112
pull_request:
1213
branches: [main]
1314
paths:
1415
- services/legacy-tileserver/**
16+
- py-modules/tileserver-utils/**
1517
jobs:
1618
docker:
1719
runs-on: ubuntu-latest
1820
steps:
1921
- name: Checkout
20-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2123
with:
2224
submodules: "recursive"
2325
# Set up python and poetry
24-
- name: Set up Python
25-
uses: actions/setup-python@v4
26-
with:
27-
python-version: 3.11
28-
- name: Install Poetry
29-
run: python3 -m pip install poetry==2.1.1
30-
- name: Build and stage local packages
31-
run: scripts/prepare-services
3226
- name: Get the version from the tag, if it exists
3327
run: |
3428
TAG=${{ github.ref_name }}
3529
VERSION=$(echo "${TAG}" | sed -E 's/legacy-tileserver-v//')
3630
echo "VERSION=${VERSION}" >> $GITHUB_ENV
37-
- name: Docker meta
31+
32+
- name: Docker metadata
3833
id: meta
3934
uses: docker/metadata-action@v4
4035
with:
@@ -44,16 +39,8 @@ jobs:
4439
type=ref,event=pr,suffix=-{{date 'YYYYMMDDHHmmss'}}
4540
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
4641
type=raw,value=latest,enable={{is_default_branch}}
42+
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable={{is_default_branch}}
4743
type=raw,value=sha-{{sha}}
48-
49-
50-
# When a PRODUCTION tag (legacy-tileserver-vX.Y.Z) → also tag staging and dev
51-
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && !contains(env.VERSION, '-') }}
52-
type=raw,value=${{ env.VERSION }}-beta.{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && !contains(env.VERSION, '-') }}
53-
type=raw,value=${{ env.VERSION }}-beta,enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && !contains(env.VERSION, '-') }}
54-
55-
# When a STAGING prerelease tag (legacy-tileserver-vX.Y.Z-*) → also tag dev
56-
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && contains(env.VERSION, '-') }}
5744
5845
- name: Set up Docker BuildX
5946
uses: docker/setup-buildx-action@v2
@@ -67,6 +54,8 @@ jobs:
6754
uses: docker/build-push-action@v5
6855
with:
6956
context: services/legacy-tileserver
57+
build-contexts: |
58+
py-modules=./py-modules
7059
push: true
7160
tags: ${{ steps.meta.outputs.tags }}
7261
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/build-tileserver.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: ["main"]
66
paths:
77
- services/tileserver/**
8+
- py-modules/tileserver-utils/**
89
tags:
910
- tileserver-v[0-9]+.[0-9]+.[0-9]+ # Semver Release (non-prerelease)
1011
- tileserver-v[0-9]+.[0-9]+.[0-9]+-** # Semver release (prerelease)
@@ -18,16 +19,10 @@ jobs:
1819
runs-on: ubuntu-latest
1920
steps:
2021
- name: Checkout
21-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2223
with:
2324
submodules: "recursive"
24-
# Set up python and poetry
25-
- name: Set up Python
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: 3.11
29-
- name: Install Poetry
30-
run: python3 -m pip install poetry==2.1.1
25+
3126
- name: Get the version from the tag, if it exists
3227
run: |
3328
TAG=${{ github.ref_name }}

local-root/docker-compose.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,18 @@ services:
9393
# This is necessary for the tileserver to correctly generate URLs for tilejson files.
9494
# https://github.com/encode/starlette/issues/538
9595
command: >
96-
uvicorn --host 0.0.0.0 --port 8000
96+
uv run uvicorn --host 0.0.0.0 --port 8000
9797
macrostrat.tileserver:app
9898
--root-path /tiles
9999
--log-level debug
100100
--proxy-headers
101101
--forwarded-allow-ips=*
102102
legacy_tileserver:
103-
build: ../services/legacy-tileserver
103+
image: hub.opensciencegrid.org/macrostrat/legacy-tileserver:main
104+
build:
105+
context: ../services/legacy-tileserver
106+
additional_contexts:
107+
py-modules: ../py-modules
104108
environment:
105109
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/${POSTGRES_DB}
106110
command: >

py-modules/tileserver-utils/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "macrostrat.tileserver-utils"
33
version = "0.1.0"
44
description = "Utilities for Macrostrat tile servers"
55
authors = [{ name = "Daven Quinn", email = "[email protected]" }]
6-
requires-python = ">=3.11,<4.0"
6+
requires-python = ">=3.9,<4.0"
77
readme = "README.md"
88
dependencies = [
99
"starlette (>=0.37.0,<0.47.0)",

services/api-v3/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ ADD . /services/main
1818
RUN --mount=type=cache,target=/root/.cache/uv \
1919
uv sync --locked
2020

21+
EXPOSE 80
22+
2123
CMD ["uv", "run", "uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "80"]

services/legacy-tileserver/Dockerfile

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,32 @@ RUN npm install -g carto
5656
# Clear temporary files
5757
RUN rm -rf /tmp/*
5858

59-
# The rest of this (for vector tile generation and the server itself) should be easier.
59+
# The rest of this (for the server itself) should be easier.
6060

61+
# Install UV
62+
COPY --from=ghcr.io/astral-sh/uv:0.9.9 /uv /uvx /bin/
6163

62-
RUN pip install --no-cache-dir "pip==25.1.1" && pip install --no-cache-dir "poetry==2.1.1"
64+
ENV UV_LINK_MODE=copy
65+
ENV UV_COMPILE_BYTECODE=1
6366

67+
# NEED TO specify a build context for the py-modules directory
68+
COPY --from=py-modules tileserver-utils /py-modules/tileserver-utils
6469

65-
# Copy only requirements to cache them in docker layer
66-
# Right now, Poetry lock file must exist to avoid hanging on dependency resolution
67-
COPY ./pyproject.toml ./poetry.lock /app/
70+
WORKDIR /services/main
6871

69-
# Create and activate our own virtual envrionment so that we can keep
70-
# our application dependencies separate from Poetry's
72+
# Install dependencies
73+
RUN --mount=type=cache,target=/root/.cache/uv \
74+
--mount=type=bind,source=uv.lock,target=uv.lock \
75+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
76+
--mount=type=bind,source=deps,target=deps \
77+
uv sync --locked --no-install-project --no-editable --active
7178

72-
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --no-root --without dev --without local
79+
# Add source files to project
80+
ADD . /services/main
7381

74-
# This gets locally built deps, which must be staged in the
75-
# image directory before building. This is breakable and we'd like
76-
# to end up with a better solution eventually.
77-
COPY ./deps/ /app/deps/
78-
79-
# Install local wheels without caring about hashes (poetry gets mad if package hashes don't match.)
80-
RUN pip install --no-cache-dir ./deps/*.whl
81-
82-
# Creating folders, and files for a project:
83-
COPY ./ /app/
84-
85-
# Install the root package
86-
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev
82+
# Sync the project
83+
RUN --mount=type=cache,target=/root/.cache/uv \
84+
uv sync --locked --no-editable --active
8785

8886
EXPOSE 8000
8987

services/legacy-tileserver/uv.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/tileserver/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ ADD . /services/main
4444
RUN --mount=type=cache,target=/root/.cache/uv \
4545
uv sync --locked --no-editable
4646

47+
EXPOSE 8000
48+
4749
CMD ["uv", "run", "uvicorn", "--host", "0.0.0.0", "--port", "8000", "macrostrat.tileserver:app" ]

0 commit comments

Comments
 (0)