Skip to content

Commit d06c8f8

Browse files
committed
Update Docker config and testing for src-layout
Fix syntax warning in dockerfile Update dockerfile for src-layout Rejig dev api container to accommodate src-layout and add dev container healthcheck Fix docker build Disable fail fast Combine dev docker builds into one job
1 parent 5fb4411 commit d06c8f8

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

.docker/app_dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM node:20-bullseye as base
2+
FROM node:20-bullseye AS base
33
SHELL ["/bin/bash", "--login", "-c"]
44

55
WORKDIR /app

.docker/server_dockerfile

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM python:3.10 as base
2+
FROM python:3.10 AS base
33
SHELL ["/bin/bash", "--login", "-c"]
44

55
# Useful for installing deps from git, preventing big downloads and bandwith quotas
@@ -16,24 +16,29 @@ FROM base as app
1616

1717
WORKDIR /app
1818

19-
# Set up uv venv in /opt/.venv to avoid polluting the mounted /app dir
20-
RUN pip install uv
19+
COPY --from=ghcr.io/astral-sh/uv:0.4 /uv /usr/local/bin/uv
20+
ENV UV_LINK_MODE=copy \
21+
UV_COMPILE_BYTECODE=1 \
22+
UV_PYTHON_DOWNLOADS=never \
23+
UV_PROJECT_ENVIRONMENT=/opt/.venv \
24+
UV_PYTHON=python3.10
25+
2126
WORKDIR /opt
27+
COPY pydatalab/pyproject.toml /_lock/
28+
COPY pydatalab/uv.lock /_lock/
29+
COPY pydatalab/requirements/requirements-all.txt /_lock/
2230
RUN uv venv
31+
RUN uv pip install -r /_lock/requirements-all.txt
2332

24-
COPY pydatalab/requirements/requirements-all.txt .
25-
RUN uv pip install -r requirements-all.txt
26-
27-
WORKDIR /app
28-
COPY pydatalab/pyproject.toml .
2933
# Create development image using flask's dev server with hot-reload
3034
FROM app as development
3135

32-
ENV FLASK_APP "pydatalab.main:create_app()"
36+
37+
WORKDIR /app
38+
ENV FLASK_APP "pydatalab.main"
3339
ENV FLASK_ENV "development"
3440
ENV PORT=5001
35-
36-
CMD ["/bin/bash", "-c", "/opt/.venv/bin/python -m flask run --reload --port ${PORT} --host 0.0.0.0"]
41+
CMD [ "/bin/bash", "-c", "source /opt/.venv/bin/activate && exec flask run --reload --port ${PORT} --host 0.0.0.0" ]
3742

3843
# Create production image using gunicorn and minimal dependencies
3944
FROM app as production
@@ -54,8 +59,8 @@ ENV PORT=${PORT}
5459

5560
# Install the local version of the package and mount the repository data to get version info
5661
RUN git config --global --add safe.directory /
57-
RUN --mount=type=bind,target=/.git,source=./.git ["uv", "pip", "install", "--python", "/opt/.venv/bin/python", "."]
62+
RUN --mount=type=bind,target=/.git,source=./.git ["uv", "pip", "install", "--python", "/opt/.venv/bin/python", "--no-deps", "."]
5863

5964
CMD ["/bin/bash", "-c", "/opt/.venv/bin/python -m gunicorn --preload -w ${WEB_CONCURRENCY} --error-logfile /logs/pydatalab_error.log --access-logfile - -b 0.0.0.0:${PORT} 'pydatalab.main:create_app()'"]
6065

61-
HEALTHCHECK --interval=30s --timeout=30s --start-interval=5s --start-period=30s --retries=3 CMD curl --fail http://localhost:${PORT}/healthcheck/is_ready || exit 1
66+
HEALTHCHECK --interval=30s --timeout=30s --start-interval=15s --start-period=30s --retries=3 CMD curl --fail http://localhost:${PORT}/healthcheck/is_ready || exit 1

.github/workflows/ci.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@ jobs:
123123
docker:
124124
name: Test dev Docker builds
125125
runs-on: ubuntu-latest
126-
strategy:
127-
matrix:
128-
target:
129-
- "app_dev"
130-
- "api_dev"
131-
- "database_dev"
132126

133127
steps:
134128
- uses: actions/checkout@v4
@@ -143,8 +137,20 @@ jobs:
143137
load: true
144138
targets: ${{ matrix.target }}
145139
set: |
146-
*.cache-to=type=gha,scope=build-${{ matrix.target }},mode=max
147-
*.cache-from=type=gha,scope=build-${{ matrix.target }}
140+
app_dev.cache-to=type=gha,scope=build-app_dev,mode=max
141+
app_dev.cache-from=type=gha,scope=build-app_dev
142+
app_dev.tags=datalab-app_dev:latest
143+
api_dev.cache-to=type=gha,scope=build-api_dev,mode=max
144+
api_dev.cache-from=type=gha,scope=build-api_dev
145+
api_dev.tags=datalab-api_dev:latest
146+
database_dev.cache-to=type=gha,scope=build-database-dev,mode=max
147+
database_dev.cache-from=type=gha,scope=build-database_dev
148+
database_dev.tags=datalab-database_dev:latest
149+
150+
- name: Start services
151+
run: |
152+
# Launch dev container profiles and wait for them to come up with healthchecks
153+
docker compose up app_dev api_dev database_dev --wait --no-build --force-recreate -d
148154
149155
e2e:
150156
name: e2e tests

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ services:
6464
volumes:
6565
- ./logs:/logs
6666
- ./.git:/.git
67-
- ./pydatalab:/app
67+
- ./pydatalab/src:/app
6868
ports:
6969
- "5001:5001"
7070
networks:

0 commit comments

Comments
 (0)