diff --git a/docker/klipper/Dockerfile b/docker/klipper/Dockerfile index 1d74b9d..1053d70 100644 --- a/docker/klipper/Dockerfile +++ b/docker/klipper/Dockerfile @@ -8,7 +8,8 @@ WORKDIR /opt RUN git clone ${REPO} klipper \ && cd klipper \ - && git checkout ${VERSION} + && git checkout ${VERSION} \ + && rm -rf .git RUN virtualenv -p python2 venv \ && venv/bin/pip install -r klipper/scripts/klippy-requirements.txt \ @@ -20,15 +21,15 @@ RUN virtualenv -p python2 venv \ FROM python:2-slim as run WORKDIR /opt -COPY --from=build /opt/klipper ./klipper -COPY --from=build /opt/venv ./venv - -RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/config RUN groupadd klipper --gid 1000 \ && useradd klipper --uid 1000 --gid klipper \ - && usermod klipper --append --groups dialout \ + && usermod klipper --append --groups dialout +RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/config \ && chown -R klipper:klipper /opt/* +COPY --chown=klipper:klipper --from=build /opt/klipper ./klipper +COPY --chown=klipper:klipper --from=build /opt/venv ./venv + USER klipper VOLUME ["/opt/printer_data/run", "/opt/printer_data/gcodes", "/opt/printer_data/logs", "/opt/printer_data/config"] ENTRYPOINT ["/opt/venv/bin/python", "klipper/klippy/klippy.py"] @@ -38,9 +39,6 @@ CMD ["-I", "printer_data/run/klipper.tty", "-a", "printer_data/run/klipper.sock" FROM ubuntu:18.04 as mcu WORKDIR /opt -COPY --from=build /opt/klipper ./klipper -COPY --from=build /opt/venv ./venv - ARG DEBIAN_FRONTEND=noninteractive RUN apt update \ && apt install -y \ @@ -53,6 +51,9 @@ RUN apt update \ python3-numpy python3-matplotlib \ && apt clean +COPY --chown=klipper:klipper --from=build /opt/klipper ./klipper +COPY --chown=klipper:klipper --from=build /opt/venv ./venv + ## Build klipper.elf for Simulavr and Simulavr itself FROM mcu as build-simulavr @@ -67,17 +68,17 @@ COPY config.simulavr .config RUN make WORKDIR /opt +RUN mkdir run +RUN groupadd simulavr --gid 1000 \ + && useradd simulavr --uid 1000 --gid simulavr \ + && usermod simulavr --append --groups dialout + RUN git clone git://git.savannah.nongnu.org/simulavr.git \ && cd simulavr \ && git checkout release-1.1.0 \ && make python \ - && make build - -RUN mkdir run -RUN groupadd simulavr --gid 1000 \ - && useradd simulavr --uid 1000 --gid simulavr \ - && usermod simulavr --append --groups dialout \ - && chown -R simulavr:simulavr /opt/* + && make build \ + && chown -R simulavr:simulavr /opt/simulavr USER simulavr ENV PYTHONPATH=/opt/simulavr/build/pysimulavr/ diff --git a/docker/moonraker/Dockerfile b/docker/moonraker/Dockerfile index 9ba7943..4c4e406 100644 --- a/docker/moonraker/Dockerfile +++ b/docker/moonraker/Dockerfile @@ -8,7 +8,8 @@ WORKDIR /opt RUN git clone ${REPO} moonraker \ && cd moonraker \ - && git checkout ${VERSION} + && git checkout ${VERSION} \ + && rm -rf .git RUN python -m venv venv \ && venv/bin/pip install -r moonraker/scripts/moonraker-requirements.txt @@ -35,15 +36,15 @@ RUN apt update \ && apt clean WORKDIR /opt -COPY --from=build /opt/moonraker ./moonraker -COPY --from=build /opt/venv ./venv - -RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/database printer_data/config RUN groupadd moonraker --gid 1000 \ && useradd moonraker --uid 1000 --gid moonraker \ - && usermod moonraker --append --groups dialout \ + && usermod moonraker --append --groups dialout +RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/database printer_data/config \ && chown -R moonraker:moonraker /opt/* +COPY --chown=moonraker:moonraker --from=build /opt/moonraker ./moonraker +COPY --chown=moonraker:moonraker --from=build /opt/venv ./venv + RUN ln -s /bin/systemctl /sbin/shutdown \ && ln -s /bin/systemctl /sbin/reboot \ && echo -n "moonraker ALL = NOPASSWD: /bin/systemctl, /sbin/shutdown, /sbin/reboot" > /etc/sudoers.d/moonraker diff --git a/docker/ustreamer/Dockerfile b/docker/ustreamer/Dockerfile index f608e19..b998a32 100644 --- a/docker/ustreamer/Dockerfile +++ b/docker/ustreamer/Dockerfile @@ -20,7 +20,8 @@ RUN apt update \ RUN git clone ${REPO} ustreamer \ && cd ustreamer \ - && git checkout ${VERSION} + && git checkout ${VERSION} \ + && rm -rf .git RUN cd ustreamer \ && make @@ -39,12 +40,11 @@ RUN apt update \ && apt clean WORKDIR /opt -COPY --from=build /opt/ustreamer ./ustreamer - RUN groupadd ustreamer --gid 1000 \ && useradd ustreamer --uid 1000 --gid ustreamer \ - && usermod ustreamer --append --groups video \ - && chown -R ustreamer:ustreamer /opt/* + && usermod ustreamer --append --groups video + +COPY --chown=ustreamer:ustreamer --from=build /opt/ustreamer ./ustreamer ## Start ustreamer USER ustreamer