Added emulator for testing with docker/compose

This commit is contained in:
David Allen 2024-07-16 15:53:57 -06:00
parent e26bd175f1
commit fcd2aae259
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
3 changed files with 91 additions and 0 deletions

53
emulator/Dockerfile Normal file
View file

@ -0,0 +1,53 @@
FROM alpine:latest as base
COPY src/requirements.txt /app/requirements.txt
USER root
RUN apk -U upgrade
RUN apk add --no-cache tini bash
RUN apk add --no-cache --update \
build-base \
python3 \
python3-dev \
py3-pip \
openssl \
openssl-dev \
libffi-dev \
gcc \
musl-dev \
cargo \
curl \
--force-missing-repositories
# added python venv for MacOS builds with brew
RUN python3 -m venv ./env \
&& chmod 777 -R ./env \
&& ./env/bin/activate
RUN ./env/bin/python3 -m pip install --upgrade \
pip \
setuptools \
&& ./env/bin/python3 -m pip install wheel \
&& ./env/bin/python3 -m pip install -r /app/requirements.txt
RUN apk del \
build-base \
gcc \
python3-dev \
openssl-dev \
libffi-dev \
musl-dev \
cargo
# Insert our emulator extentions
COPY src /app
COPY mockups /app/api_emulator/redfish/static
EXPOSE 5000
ENV MOCKUPFOLDER="public-rackmount1"
ENV AUTH_CONFIG=""
ENV PORT=5000
ENV XNAME="x3000c0s0b0"
ENV MAC_SCHEMA=""
WORKDIR /app
ENTRYPOINT ["/env/bin/python3"]
CMD ["emulator.py"]

26
emulator/rf-emulator.yml Normal file
View file

@ -0,0 +1,26 @@
networks:
internal:
volumes:
emulator:
services:
emulator:
image: openchami-rie:latest
container_name: rf-emulator
environment:
BMC_PORT: 5000
MOCKUPFOLDER: EX235a
AUTH_CONFIG: "root:root_password:Administrator"
volumes:
- ./rf-emulator/mockups:/mockups
ports:
- 5000:443
networks:
- internal
healthcheck:
test: ["CMD", "curl", "--fail", "--silent", "http://127.0.0.1:5000"]
interval: 5s
timeout: 10s
retries: 10

12
emulator/setup.sh Executable file
View file

@ -0,0 +1,12 @@
#/bin/sh
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# clone the CSM redfish emulator if needed
if [ ! -d ${script_dir}/rf-emulator ]; then
git clone https://github.com/Cray-HPE/csm-redfish-interface-emulator ${script_dir}/rf-emulator
fi
# build docker image and run with docker compose
docker build -t openchami-rie:latest -f ${script_dir}/Dockerfile ${script_dir}/rf-emulator
docker compose -f ${script_dir}/rf-emulator.yml up