Skip to content

Commit

Permalink
fix: cleanup template dockerfile (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwcrft authored Oct 31, 2022
1 parent 5185483 commit 6192609
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions template.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,18 @@ ENV PYTHONFAULTHANDLER=1 \
VIRTUALENV_PIP=21.2.1 \
MYPY_VERSION=0.930


RUN pip install "poetry==$POETRY_VERSION" "mypy==$MYPY_VERSION"
# pylintrc, coveragerc, poetry.lock and pyproject.toml shall not change very
# often, so it is a good idea to add them as soon as possible
COPY .coveragerc mypy.ini .flake8 ./
COPY poetry.lock pyproject.toml ./
COPY .coveragerc mypy.ini .flake8 poetry.lock pyproject.toml ./

# During make build this sed command is substituted by 's/secc/evcc/g'
RUN sed -i 's/secc/secc/g' pyproject.toml

# Due to an issue with Python 3.10 and poetry, if we use a poetry virtual env,
# we need to disable the option: poetry config experimental.new-installer false
# check https://github.com/python-poetry/poetry/issues/4210
# However, if we run poetry config virtualenvs.create false, then we dont.
# Do not create a virtual poetry env as we already are in an isolated container
RUN poetry config virtualenvs.create false
# Install dependencies and the project in the venv
RUN poetry install --no-interaction --no-ansi

# Copy the project to the system
COPY iso15118/ iso15118/

# Run the tests and linting
COPY tests/ tests/
RUN poetry run black --check --diff --line-length=88 iso15118 tests
RUN poetry run flake8 --config .flake8 iso15118 tests
# RUN poetry run mypy --config-file mypy.ini iso15118 tests
RUN poetry run pytest -vv --cov-config .coveragerc --cov-report term-missing --durations=3 --cov=.


# Generate the wheel to be used by next stage
RUN poetry build

Expand All @@ -54,19 +37,14 @@ FROM python:3.10.0-buster
WORKDIR /usr/src/app
# Installs Java
RUN apt update && apt install -y default-jre
# create virtualenv
# Create virtualenv
RUN python -m venv /venv
# copy dependencies and wheel from the build stage
# Copy dependencies and wheel from the build stage
COPY --from=build /usr/src/app/dist/ dist/
# This will install the wheel in the venv
RUN /venv/bin/pip install dist/*.whl


# Generating the certs inside the container didn't work (error: Certificate verification failed), but the command is kept
# here so we can investigate this issue later on
# RUN cd /venv/lib/python3.10/site-packages/iso15118/shared/pki && ./create_certs.sh -v iso-2

# This is not the ideal way to provide the certificate chain to the container, but for now it works
# Replace with in-container cert generation DevOps#2664
COPY --from=build /usr/src/app/iso15118/shared/pki/ /usr/src/app/iso15118/shared/pki/

RUN /venv/bin/pip install aiofile
Expand Down

0 comments on commit 6192609

Please sign in to comment.