-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
75 lines (51 loc) · 1.96 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
ARG PYTHON_VER
FROM python:${PYTHON_VER:?} AS python-base
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
FROM python-base AS poetry
RUN --mount=type=cache,target=/root/.cache pip install poetry
RUN python -m venv /venv
ENV VIRTUAL_ENV=/venv \
PATH="/venv/bin:$PATH"
RUN poetry config virtualenvs.create false
WORKDIR /workspace
COPY pyproject.toml poetry.lock /workspace/
# Poetry needs these to exist to setup the editable install
RUN mkdir -p src/v8serialize && touch src/v8serialize/__init__.py README.md
RUN --mount=type=cache,target=/root/.cache poetry install
FROM poetry AS test
RUN --mount=source=.,target=/workspace,rw \
--mount=type=cache,uid=1000,target=.pytest_cache \
--mount=type=cache,uid=1000,target=.hypothesis \
pytest
FROM poetry AS lint-setup
# invalidate cache so that the lint tasks run. We use no-cache-filter here but
# not on the lint-* tasks so that the tasks can mount cache dirs themselves.
RUN touch .now
FROM lint-setup AS lint-check
RUN --mount=source=.,target=/workspace,rw \
ruff check src test
FROM lint-setup AS lint-format
RUN --mount=source=.,target=/workspace,rw \
poetry run ruff format --check --diff .
FROM lint-setup AS lint-mypy
RUN --mount=source=.,target=/workspace,rw \
--mount=type=cache,target=.mypy_cache \
poetry run mypy .
FROM poetry AS smoketest-pkg-build
RUN --mount=source=testing/smoketest,target=.,rw \
mkdir /dist && poetry build -o /dist
FROM scratch AS smoketest-pkg
COPY --from=smoketest-pkg-build /dist/* .
FROM poetry AS v8serialize-pkg-build
RUN --mount=source=.,target=/workspace,rw \
mkdir /dist && poetry build -o /dist
FROM scratch AS v8serialize-pkg
COPY --from=v8serialize-pkg-build /dist/* .
FROM python-base AS test-package
RUN python -m venv /env
ENV PATH=/env/bin:$PATH
RUN --mount=from=smoketest-pkg,target=/pkg/smoketest \
--mount=from=v8serialize-pkg,target=/pkg/v8serialize \
pip install /pkg/smoketest/*.whl /pkg/v8serialize/*.whl
RUN pip list
RUN python -m smoketest