Closed bergtwvd closed 5 years ago
Only tested on CRC license file, but something like following Dockerfile should work. The entryoint script is generic for any data image and provides flexibilty for copying the data once the image has been built.
Following (to be adapted) command builds image:
docker build --build-arg SRC=/my/data/directory -t app-docker136.hex.tno.nl/dataimage
Dockerfile:
FROM busybox
ENTRYPOINT [ "sh", "-c", " \
if [ -n \"$VOLUME\" -a -n \"$1\" ]; then \
if [ -n \"$OPTS\" ]; then \
cp $OPTS $VOLUME $1; \
else \
cp -a $VOLUME $1; \
fi; \
echo \"Copied $VOLUME to $1\"; \
fi" , \
"--" ]
ARG SRC
ENV VOLUMEDIR /data
ENV VOLUME ${VOLUMEDIR}/.
COPY ${SRC} ${VOLUMEDIR}/
VOLUME ${VOLUMEDIR}
Fix tested for msg134/ts-hla-encoding-rules-tester:1.0.1
. Result OK.
Now to do: HelloWorld
and msg134/runtime-config:development-latest
. TBC.
This is now pushed as well. But the runtime config adds three folders, and the dockerfile only provides one mount point so I'm not sure if this will go well provided that the TS also go into /root/conf/
ADD IVCT.properties /root/conf/IVCT.properties
ADD IVCTsut /root/conf/IVCTsut
ADD Badges /root/conf/Badges
ENV VOLUMEDIR /root/conf/
ENV VOLUME ${VOLUMEDIR}/.
VOLUME ${VOLUMEDIR}
ENTRYPOINT [ "sh", "-c", "if [ -n \"$1\" ]; then cp -r /root/conf/* $1; echo \"Copied data to $1\"; else /bin/true; fi", "--" ]
Fixed with the new entrypoint script.
Under Docker the TS data in the
ts-hla-encoding-rules-tester
data container is located under/root/conf/TestSuites/TS_HLA_EncodingRulesTester
. The runner in the shipsim composition (https://github.com/MSG134/IVCT_Compositions/blob/master/Shipsim/pi-docker-compose.yml) expects the data under/root/conf/TestSuites/TS_HLA_EncodingRulesTester-1.0.1
. This is solved in the docker compose file by mounting the volume data in the expected directory.However, this does not work under Kubernetes, where volume initialisation is done differently w.r.t. Docker. In Kubernetes we need to do volume initialization ourselves using a script in the data container entrypoint:
So, in this example, the data ends up at
/TS_HLA_EncodingRulesTester
in the data volume. If we then mount this volume at/root/conf/TestSuites/TS_HLA_EncodingRulesTester-1.0.1
, then for the runner the data is actually under:/root/conf/TestSuites/TS_HLA_EncodingRulesTester-1.0.1/TS_HLA_EncodingRulesTester
!!To fix this for the short term, the data directory in the data container should be named
TS_HLA_EncodingRulesTester-1.0.1
instead ofTS_HLA_EncodingRulesTester
.