Skip to content

Commit

Permalink
Merge pull request #197 from Wawszczak/docker-persistent
Browse files Browse the repository at this point in the history
Allow OpenPlc Configuration storage outside container in Docker Volumes
  • Loading branch information
thiagoralves authored Apr 5, 2023
2 parents 9a2f14b + e15cde4 commit 5a00f03
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
FROM debian:bullseye-20211201

COPY . /workdir
WORKDIR /workdir
RUN mkdir /persistent
VOLUME /persistent
RUN ./install.sh docker
RUN touch /persistent/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"]
25 changes: 25 additions & 0 deletions webserver/scripts/start_openplc.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
#!/bin/bash
if [[ ! -d "/persistent" ]]
then
mkdir /persistent
fi
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

0 comments on commit 5a00f03

Please sign in to comment.