Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend everest docker image with OCPP 2.0.1 compatibility #129

Merged
merged 19 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions docker/everest-docker-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# syntax=docker/dockerfile:1
FROM debian:11 AS builder
FROM debian:12-slim AS builder

ARG REPO
ARG BRANCH
ARG EVEREST_CONFIG
ARG OCPP_CONFIG
ARG ADDITIONAL_CMAKE_PARAMETERS

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
Expand All @@ -20,7 +21,7 @@ RUN apt-get update \
cppcheck \
libboost-all-dev \
maven \
openjdk-11-jdk \
openjdk-17-jdk \
nodejs \
npm \
libsqlite3-dev \
Expand All @@ -29,6 +30,7 @@ RUN apt-get update \
libcurl4-openssl-dev \
libpcap-dev \
libcap-dev \
python3-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -43,7 +45,9 @@ RUN ssh-keyscan github.com > ~/.ssh/known_hosts

RUN mkdir -p /workspace/everest/cpm_source_cache
ENV CPM_SOURCE_CACHE="/workspace/everest/cpm_source_cache"

ENV EVEREST_VENV=/workspace/everest/venv
RUN python3 -m venv ${EVEREST_VENV}
ENV PATH="${EVEREST_VENV}/bin:${PATH}"
RUN git clone https://github.com/EVerest/everest-cmake.git
RUN git clone https://github.com/EVerest/everest-utils.git
WORKDIR /workspace/everest/everest-utils/ev-dev-tools
Expand All @@ -54,6 +58,8 @@ WORKDIR /workspace/everest/everest-dev-environment/dependency_manager
RUN python3 -m pip install .
WORKDIR /workspace/everest
RUN git clone https://github.com/EVerest/ext-switchev-iso15118.git
WORKDIR /workspace/everest/ext-switchev-iso15118/
RUN pip install -r requirements.txt

WORKDIR /workspace/everest

Expand All @@ -65,9 +71,11 @@ RUN rm -rf "/workspace/everest/$(basename "${REPO}" .git)/build" && \
git checkout "${BRANCH}" && \
mkdir "/workspace/everest/$(basename "${REPO}" .git)/build" && \
cd "/workspace/everest/$(basename "${REPO}" .git)/build" && \
cmake .. -DEVEREST_BUILD_ALL_MODULES=ON -DCMAKE_INSTALL_PREFIX=/opt/everest && \
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/everest ${ADDITIONAL_CMAKE_PARAMETERS} && \
make -j"$(nproc)" install

# Try to copy the OCPP 2.0.1 config directory to have the init_device_model_db.py script available for (re-)initialization of the device model
RUN cp -R "$(grep -m 1 "ocpp_SOURCE_DIR:STATIC=" "/workspace/everest/$(basename "${REPO}" .git)/build/CMakeCache.txt" | sed "s/ocpp_SOURCE_DIR:STATIC=//")/config/v201" /opt/everest/ocpp201config || echo "Could not copy OCPP 2.0.1 config directory"
RUN mkdir -p /opt/everest/config/user-config
COPY "${EVEREST_CONFIG}" /opt/everest/config/
COPY "${OCPP_CONFIG}" /opt/everest/config/
Expand All @@ -77,11 +85,11 @@ RUN if [ "${OCPP_CONFIG}" != "ocpp-config.json" ]; then mv /opt/everest/config/"
COPY logging.ini /opt/everest/config

# syntax=docker/dockerfile:1
FROM debian:11-slim
FROM debian:12-slim

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
openjdk-11-jre \
openjdk-17-jre \
nodejs \
npm \
python3-pip \
Expand All @@ -90,17 +98,22 @@ RUN apt-get update \
libboost-log1.74.0 \
libboost-chrono1.74.0 \
libboost-system1.74.0 \
libssl1.1 \
libssl3 \
libcurl4 \
libcap2 \
less \
libevent-dev \
python3-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /workspace/everest/ext-switchev-iso15118/requirements.txt ./
RUN pip install --user -r requirements.txt
ENV EVEREST_VENV=/workspace/everest/venv
RUN python3 -m venv ${EVEREST_VENV}
ENV PATH="${EVEREST_VENV}/bin:${PATH}"
COPY --from=builder /workspace/everest/venv /workspace/everest/venv

WORKDIR /opt/everest
COPY --from=builder /opt/everest ./
COPY ./scripts/initialize.sh /opt/everest

CMD [ "/opt/everest/bin/manager", "--conf", "/opt/everest/config/config.yaml" ]
6 changes: 5 additions & 1 deletion docker/everest-docker-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ Specify the following options to create your desired docker image of EVerest:
* conf: Path to EVerest config file (e.g. /home/$(whoami)/checkout/everest-workspace/everest-core/config/ config-sil.yaml) - Required.
* ocpp-conf: Path to EVerest OCPP config file (e.g. /home/$(whoami)/checkout/everest-workspace/libocpp/aux/config-docker.json) - Optional, defaults to: ocpp-config.json
* name: Name of the docker image (e.g everest-core) - Optional, defaults to: everest-core
* build-date: Build date of the docker image, is reflected in its name and can have an effect on caching - Optional, defaults to the current datetime

```bash
./build.sh [--repo <GIT-REPOSITORY>] [--branch <BRANCH-NAME>] [--conf <EVEREST-CONFIG>] [--ocpp-conf <OCPP-CONFIG>] [--name <IMAGE-NAME>]
./build.sh [--repo <GIT-REPOSITORY>] [--branch <BRANCH-NAME>] [--conf <EVEREST-CONFIG>] [--ocpp-conf <OCPP-CONFIG>] [--name <IMAGE-NAME>] [--build-date 2042]
```
Remember to provide an ocpp configuration file if you use an EVerest config that loads the OCPP module. Be aware that the provided OCPP config file will always be named `ocpp-config.json` inside the docker container. Consider this when configuring the OCPP module within the EVerest config and to set the ChargePointConfigPath accordingly.

Expand All @@ -35,3 +36,6 @@ To run the image in a docker container, run the following commands
docker load < <YOUR_IMAGE-TIMESTAMP.tar.gz>
docker run --rm -it --network host <IMAGE_NAME>
```

## Run EVerest with OCPP 2.0.1 in docker
To run EVerest with OCPP 2.0.1 you can use the provided docker-compose.yaml with the example run-ac-pwm.sh script
37 changes: 33 additions & 4 deletions docker/everest-docker-image/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ usage() {
echo -e "\t--conf: Path to EVerest config file - Required"
echo -e "\t--ocpp-conf: Path to EVerest OCPP config file - Optional, no default"
echo -e "\t--name: Name of the docker image - Optional, defaults to: everest-core"
echo -e "\t--build-date: Build date of the docker image, is reflected in its name and can have an effect on caching - Optional, defaults to the current datetime"
echo -e "\t--no-ssh: Do not append \"--ssh default\" to docker build - Optional"
echo -e "\t--container-runtime: Set container runtime (e.g. docker or podman) for build - Optional"
echo -e "\t--additional-cmake-parameters: Set additional cmake parameters for build - Optional, default \"-DEVEREST_BUILD_ALL_MODULES=ON\""
exit 1
}

ssh_param="--ssh=default"
container_runtime="docker"
additional_cmake_parameters="-DEVEREST_BUILD_ALL_MODULES=ON"

while [ ! -z "$1" ]; do
if [ "$1" == "--repo" ]; then
repo="${2}"
Expand All @@ -26,6 +34,18 @@ while [ ! -z "$1" ]; do
elif [ "$1" == "--branch" ]; then
branch="${2}"
shift 2
elif [ "$1" == "--build-date" ]; then
build_date="${2}"
shift 2
elif [ "$1" == "--no-ssh" ]; then
ssh_param=""
shift 1
elif [ "$1" == "--container-runtime" ]; then
container_runtime="${2}"
shift 2
elif [ "$1" == "--additional-cmake-parameters" ]; then
additional_cmake_parameters="${2}"
shift 2
else
usage
break
Expand Down Expand Up @@ -60,13 +80,22 @@ if [ -z "${branch}" ]; then
branch="main"
fi


NOW=$(date +"%Y-%m-%d-%H-%M-%S")
DOCKER_BUILDKIT=1 docker build \

if [ -n "${build_date}" ]; then
NOW="${build_date}"
fi

echo "Build date: ${NOW}"
echo "Using container runtime \"${container_runtime}\" for building. Version: $(${container_runtime} --version)"
echo "Additional CMake parameters for EVerest build: \"${additional_cmake_parameters}\""
trap 'echo "Build not successful"; exit 1' ERR
DOCKER_BUILDKIT=1 ${container_runtime} build \
--build-arg BUILD_DATE="${NOW}" \
--build-arg REPO="${repo}" \
--build-arg EVEREST_CONFIG="${conf}" \
--build-arg OCPP_CONFIG="${ocpp_conf}" \
--build-arg BRANCH="${branch}" \
-t "${name}" --ssh default .
docker save "${name}":latest | gzip >"$name-${NOW}.tar.gz"
--build-arg ADDITIONAL_CMAKE_PARAMETERS="${additional_cmake_parameters}" \
-t "${name}" "${ssh_param}" .
${container_runtime} save "${name}":latest | gzip >"$name-${NOW}.tar.gz"
195 changes: 195 additions & 0 deletions docker/everest-docker-image/configuration/everest/config-ac-hlc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
active_modules:
iso15118_charger:
module: EvseV2G
config_module:
device: auto
tls_security: allow
verify_contract_cert_chain: false
connections:
security:
- module_id: evse_security
implementation_id: main
iso15118_car:
module: PyEvJosev
config_module:
device: auto
supported_ISO15118_2: true
tls_active: true
is_cert_install_needed: true
evse_manager_1:
module: EvseManager
config_module:
connector_id: 1
three_phases: true
has_ventilation: true
country_code: DE
evse_id: "DE*PNX*00001"
session_logging: true
session_logging_xml: false
session_logging_path: /opt/everest/logs/evse_1
ac_hlc_enabled: true
ac_hlc_use_5percent: false
ac_enforce_hlc: false
connections:
bsp:
- module_id: yeti_driver_1
implementation_id: board_support
powermeter_grid_side:
- module_id: yeti_driver_1
implementation_id: powermeter
slac:
- module_id: slac
implementation_id: evse
hlc:
- module_id: iso15118_charger
implementation_id: charger
evse_manager_2:
module: EvseManager
config_module:
connector_id: 2
three_phases: true
has_ventilation: true
country_code: DE
evse_id: "2"
session_logging: true
session_logging_xml: false
session_logging_path: /opt/everest/logs/evse_2
ac_hlc_enabled: false
ac_hlc_use_5percent: false
ac_enforce_hlc: false
connections:
bsp:
- module_id: yeti_driver_2
implementation_id: board_support
powermeter_grid_side:
- module_id: yeti_driver_2
implementation_id: powermeter
slac:
- module_id: slac
implementation_id: evse
hlc:
- module_id: iso15118_charger
implementation_id: charger
yeti_driver_1:
module: JsYetiSimulator
config_module:
connector_id: 1
yeti_driver_2:
module: JsYetiSimulator
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
car_simulator_1:
module: JsCarSimulator
config_module:
connector_id: 1
auto_enable: true
auto_exec: false
auto_exec_commands: sleep 1;iec_wait_pwr_ready;sleep 1;draw_power_regulated 16,3;sleep 30;unplug
connections:
simulation_control:
- module_id: yeti_driver_1
implementation_id: yeti_simulation_control
ev:
- module_id: iso15118_car
implementation_id: ev
slac:
- module_id: slac
implementation_id: ev
car_simulator_2:
module: JsCarSimulator
config_module:
connector_id: 2
auto_enable: true
auto_exec: false
connections:
simulation_control:
- module_id: yeti_driver_2
implementation_id: yeti_simulation_control
ev:
- module_id: iso15118_car
implementation_id: ev
slac:
- module_id: slac
implementation_id: ev
# TODO: add OCPP config path!
ocpp:
module: OCPP201
config_module:
MessageLogPath: /opt/everest/logs/ocpp
connections:
evse_manager:
- module_id: evse_manager_1
implementation_id: evse
- module_id: evse_manager_2
implementation_id: evse
auth:
- module_id: auth
implementation_id: main
system:
- module_id: system
implementation_id: main
security:
- module_id: evse_security
implementation_id: main
evse_security:
module: EvseSecurity
config_module:
private_key_password: "123456"
token_provider_1:
module: DummyTokenProviderManual
auth:
module: Auth
config_module:
connection_timeout: 120
selection_algorithm: PlugEvents
connections:
token_provider:
- module_id: token_provider_1
implementation_id: main
- module_id: ocpp
implementation_id: auth_provider
- module_id: evse_manager_1
implementation_id: token_provider
- module_id: evse_manager_2
implementation_id: token_provider
token_validator:
- module_id: ocpp
implementation_id: auth_validator
evse_manager:
- module_id: evse_manager_1
implementation_id: evse
- module_id: evse_manager_2
implementation_id: evse
energy_manager:
module: EnergyManager
connections:
energy_trunk:
- module_id: grid_connection_point
implementation_id: energy_grid
grid_connection_point:
module: EnergyNode
config_module:
fuse_limit_A: 40.0
phase_count: 3
connections:
price_information: []
energy_consumer:
- module_id: evse_manager_1
implementation_id: energy_grid
- module_id: evse_manager_2
implementation_id: energy_grid
powermeter:
- module_id: yeti_driver_1
implementation_id: powermeter
api:
module: API
connections:
evse_manager:
- module_id: evse_manager_1
implementation_id: evse
system:
module: System

x-module-layout: {}
Loading
Loading