Open dcihlar opened 3 years ago
@dcihlar, can you please rewrite the Dockerfile to use multi-stage builds?
Target image should not have to carry build dependencies (autotools, git, python2-dev, libfreetype6-dev, libpng-dev) once the builder image completed installing the runtime dependencies.
While FROM debian:buster
is 110MB, the very next RUN adds 880MB of packages (without issuing apt-get clean
), and RUN install.sh adds some 360MB more. The resulting build is 1.36 GB for a single tool (Beremiz/wxpython+matiec+gcc)
My Docker-fu is not strong enough :smile:
Okay, I rewrote it myself. Dropped 1.36GiB to 1.18GiB image on latest debian:buster by removing a bunch of -dev packages. Multi-stage builds are not an option since install.sh uses pip to build some packages and OpenPLC requires gcc at runtime.
Looks working on my machine (GUI, PLC compilation, local debugging). The bulid and run commands are the same.
FROM debian:buster
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-utils coreutils curl bash-completion git python2 sudo
# Compilers for matiec and pip
RUN apt-get install -y --no-install-recommends \
build-essential pkg-config bison flex autoconf automake libtool \
gcc make libc-dev
# Python -dev and pip
RUN apt-get install -y --no-install-recommends \
python-pip python2-dev python-all-dev python-setuptools python-wheel \
libssl-dev libxml2-dev libxslt1-dev libssl1.1 libxml2 libxslt1.1
# Graphics
RUN apt-get install -y --no-install-recommends \
python-wxgtk3.0 dbus-x11 libpng16-16 \
libpng-dev libfreetype6-dev
# password = user
RUN mkdir -p /etc/skel/.local/share/applications && \
mkdir -p /root/.local/share/applications && \
useradd user --uid 1000 -p aaBrLCcg4bKmQ --groups sudo --create-home
RUN git clone --depth 1 --single-branch https://github.com/thiagoralves/OpenPLC_Editor.git
RUN cd /OpenPLC_Editor && ./install.sh && \
cd /OpenPLC_Editor/matiec && make mostlyclean && \
mv /OpenPLC_Editor/openplc_editor.sh /usr/local/bin/openplc-editor
RUN apt-get remove -y \
build-essential autoconf automake libtool bison flex pkg-config git \
python-pip python2-dev python-all-dev \
libssl-dev libpng-dev libfreetype6-dev && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
USER user
ENV HOME=/home/user
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user/.local/bin
ENV LANG=en_US.utf8
WORKDIR /home/user
CMD openplc-editor
Works very well!! I would love to see this dockerfile on the main branch!
On the newer systems the old Python 2 is now completely gone, so installing the current OpenPLC Editor is a hassle.
I propose a Docker image as a workaround until the editor is ported to Python 3:
Build it with:
And run with: