-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.test
More file actions
44 lines (35 loc) · 1.35 KB
/
Dockerfile.test
File metadata and controls
44 lines (35 loc) · 1.35 KB
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
FROM ubuntu:latest
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y curl python3 python3-pip python3-psycopg2 python3-venv postgresql libpq-dev
# Poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
ENV POETRY_VERSION=1.7.0 \
# make poetry install to this location
POETRY_HOME="/opt/poetry" \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
# never create virtual environments, only use the venv prepared by us
POETRY_VIRTUALENVS_CREATE=false \
\
# this is where our requirements + virtual environment will live
VIRTUAL_ENV="/venv"
# prepend poetry and venv to path. Add src to python path.
ENV PATH="$POETRY_HOME/bin:$VIRTUAL_ENV/bin:$PATH"
ENV PYTHONPATH="$PYTHONPATH:/code/src"
# prepare virtual env
RUN python3 -m venv $VIRTUAL_ENV
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://install.python-poetry.org | python3 -
WORKDIR /code
# initialize dependencies
COPY poetry.lock pyproject.toml LICENSE README.md ./
# installs runtime dependencies to $VIRTUAL_ENV
RUN poetry install --with dev --extras server
COPY src ./src
COPY tests/ ./tests/
COPY mypy_stubs ./mypy_stubs/
ENV LOG_CONFIG=test
RUN useradd testuser -d /code
USER testuser
RUN --network=none poetry run pytest