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

Allow OpenPlc Configuration storage outside container in Docker Volumes #197

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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