-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (38 loc) · 1.35 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
ARG PYTHON_VER
FROM python:${PYTHON_VER:?} AS python-base
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 sortedcontainers-stubs && touch 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 \
pytest
FROM poetry AS lint-flake8
RUN --mount=source=.,target=/workspace,rw \
flake8
FROM poetry AS lint-black
RUN --mount=source=.,target=/workspace,rw \
poetry run black --check --diff .
FROM poetry AS lint-isort
RUN --mount=source=.,target=/workspace,rw \
poetry run isort --check --diff .
FROM poetry AS lint-mypy
RUN --mount=source=.,target=/workspace,rw \
--mount=type=cache,target=.mypy_cache \
poetry run mypy .
FROM python-base AS pyright
RUN apt-get update && apt-get install -y --no-install-recommends nodejs npm
RUN npm install -g pyright
WORKDIR /workspace
COPY --link --from=poetry /venv /venv
FROM pyright AS lint-pyright
RUN --mount=source=.,target=/workspace,rw \
pyright --pythonpath /venv/bin/python .