adding persistence in Docker volume feature

symlinks for:
openplc.db
persistent.file
mbconfig.cfg
dnp3.cfg
st_files
/persistent -> /workdir/webserver
paths are hardcoded in scripts/start_openplc.sh
This commit is contained in:
Stanislaw Wawszczak
2023-02-10 12:41:06 +01:00
parent a321b5423a
commit 4fb51f96da
2 changed files with 33 additions and 1 deletions

View File

@@ -5,7 +5,18 @@ RUN mkdir /persistent
VOLUME /persistent
RUN ./install.sh docker
RUN touch /persistent/mbconfig.cfg
RUN ln -s /persistent/mbconfig.cfg /workdir/webserver/mbconfig.cfg
RUN touch /persistent/persistent.file
RUN mkdir /persistent/st_files
RUN cp /workdir/webserver/openplc.db /persistent/openplc.db
RUN mv /workdir/webserver/openplc.db /workdir/webserver/openplc_default.db
RUN cp /workdir/webserver/dnp3.cfg /persistent/dnp3.cfg
RUN mv /workdir/webserver/dnp3.cfg /workdir/webserver/dnp3_default.cfg
RUN cp /workdir/webserver/st_files/* /persistent/st_files
run mv /workdir/webserver/st_files /workdir/webserver/st_files_default
RUN ln -s /persistent/mbconfig.cfg /workdir/webserver/mbconfig.cfg
RUN ln -s /persistent/persistent.file /workdir/webserver/persistent.file
RUN ln -s /persistent/openplc.db /workdir/webserver/openplc.db
RUN ln -s /persistent/dnp3.cfg /workdir/webserver/dnp3.cfg
RUN ln -s /persistent/st_files /workdir/webserver/st_files
ENTRYPOINT ["./start_openplc.sh"]

View File

@@ -1,3 +1,24 @@
#!/bin/bash
if [[ ! -f "/persistent/dnp3.cfg" ]]
then
cp /workdir/webserver/dnp3_default.cfg /persistent/dnp3.cfg
fi
if [[ ! -f "/persistent/openplc.db" ]]
then
cp /workdir/webserver/openplc_default.db /persistent/openplc.db
fi
if [[ ! -d "/persistent/st_files" ]]
then
mkdir /persistent/st_files
cp /workdir/webserver/st_files_default/* /persistent/st_files
fi
if [[ ! -f "/persistent/persistent.file" ]]
then
touch /persistent/persistent.file
fi
if [[ ! -f "/persistent/mbconfig.cfg" ]]
then
touch /persistent/mbconfig.cfg
fi
cd webserver
python2.7 webserver.py