Initial commit with the Dockerfile and necessary dependencies.

This commit is contained in:
Michael Helfrich 2022-01-31 22:34:19 -05:00
parent d58328234d
commit ed9cf13ceb
4 changed files with 189 additions and 0 deletions

74
Dockerfile Normal file
View File

@ -0,0 +1,74 @@
# Get and install Easy noVNC.
FROM golang:1.14-buster AS easy-novnc-build
WORKDIR /src
RUN go mod init build && \
go get github.com/geek1011/easy-novnc@v1.1.0 && \
go build -o /bin/easy-novnc github.com/geek1011/easy-novnc
# Get TigerVNC and Supervisor for isolating the container.
FROM debian:buster
RUN apt-get update -y && \
apt-get install -y --no-install-recommends openbox tigervnc-standalone-server supervisor gosu && \
rm -rf /var/lib/apt/lists && \
mkdir -p /usr/share/desktop-directories
# Get all of the remaining dependencies for the OS and VNC.
RUN apt-get update -y && \
apt-get install -y --no-install-recommends lxterminal nano wget openssh-client rsync ca-certificates xdg-utils htop tar xzip gzip bzip2 zip unzip && \
rm -rf /var/lib/apt/lists
RUN apt update && apt install -y --no-install-recommends --allow-unauthenticated \
lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \
freeglut3 libgtk2.0-dev libwxgtk3.0-gtk3-dev libwx-perl libxmu-dev libgl1-mesa-glx libgl1-mesa-dri xdg-utils locales \
&& apt autoclean -y \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/*
# Set the locale as this is required for Prusaslicer to work.
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Install Prusaslicer and its dependencies.
# Many of the commands below were derived and pulled from previous work by dmagyar on GitHub.
# Here's their Dockerfile for reference https://github.com/dmagyar/prusaslicer-vnc-docker/blob/main/Dockerfile.amd64
WORKDIR /slic3r
ADD get_latest_prusa_slicer_release.sh /slic3r
RUN apt-get update && apt-get install -y \
jq \
curl \
ca-certificates \
unzip \
bzip2 \
git \
--no-install-recommends \
&& chmod +x /slic3r/get_latest_prusa_slicer_release.sh \
&& latestSlic3r=$(/slic3r/get_latest_prusa_slicer_release.sh url) \
&& slic3rReleaseName=$(/slic3r/get_latest_prusa_slicer_release.sh name) \
&& curl -sSL ${latestSlic3r} > ${slic3rReleaseName} \
&& rm -f /slic3r/releaseInfo.json \
&& mkdir -p /slic3r/slic3r-dist \
&& tar -xjf ${slic3rReleaseName} -C /slic3r/slic3r-dist --strip-components 1 \
&& rm -f /slic3r/${slic3rReleaseName} \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge -y --auto-remove jq unzip bzip2 \
&& apt-get autoclean \
&& groupadd slic3r \
&& useradd -g slic3r --create-home --home-dir /slic3r slic3r \
&& mkdir -p /slic3r \
&& chown -R slic3r:slic3r /slic3r /slic3r \
&& locale-gen en_US \
&& mkdir /root/.local
COPY --from=easy-novnc-build /bin/easy-novnc /usr/local/bin/
COPY menu.xml /etc/xdg/openbox/
COPY supervisord.conf /etc/
EXPOSE 8080
VOLUME /root/
# It's time! Let's get to work! We use /root/ as a bindable volume for this Docker.
CMD ["sh", "-c", "chown slic3r:slic3r /root /dev/stdout && exec gosu slic3r supervisord"]

View File

@ -0,0 +1,66 @@
#!/bin/bash
# Get the latest release of PrusaSlicer for Linux (non-AppImage) using the GitHub API
# This was forked from https://github.com/dmagyar/prusaslicer-vnc-docker/blob/main/getLatestPrusaSlicerRelease.sh
set -eu
if [[ $# -lt 1 ]]; then
echo "~~~ $0 ~~~"
echo " usage: $0 [ url | name | url_ver VERSION | name_ver VERSION_NAME ]"
echo
echo " url: Returns the download URL for the latest release (for download using cURL/wget)"
echo " name: Returns the filename of the latest release"
echo
echo " url_ver: Takes a parameter to specify the version to retrieve (note: some download urls have hex-encoded ascii characters)"
echo " url_ver example: $0 url_ver 2.0.0%2B"
echo " output: https://github.com/prusa3d/PrusaSlicer/releases/download/version_2.0.0/PrusaSlicer-2.0.0%2Blinux64-201905201652.tar.bz2"
echo
echo " name_ver: Takes a parameter to specify the filename to retrieve (note: this has a '+' added on at the end of the provided version number)"
echo " name_ver example: $0 name_ver 2.0.0"
echo " output: PrusaSlicer-2.0.0+linux64-201905201652.tar.bz2"
echo
exit 1
fi
baseDir="/slic3r"
mkdir -p $baseDir
if [[ ! -e "$baseDir/latestReleaseInfo.json" ]]; then
curl -SsL https://api.github.com/repos/prusa3d/PrusaSlicer/releases/latest > $baseDir/latestReleaseInfo.json
fi
releaseInfo=$(cat $baseDir/latestReleaseInfo.json)
if [[ $# -gt 1 ]]; then
VER=$2
if [[ ! -e "$baseDir/releases.json" ]]; then
curl -SsL https://api.github.com/repos/prusa3d/PrusaSlicer/releases > $baseDir/releases.json
fi
allReleases=$(cat $baseDir/releases.json)
fi
if [[ "$1" == "url" ]]; then
echo "${releaseInfo}" | jq -r '.assets[] | .browser_download_url | select(test("PrusaSlicer-.+(-\\w)?.linux-x64-(?!GTK3).+.tar.bz2"))'
elif [[ "$1" == "name" ]]; then
echo "${releaseInfo}" | jq -r '.assets[] | .name | select(test("PrusaSlicer-.+(-\\w)?.linux-x64-(?!GTK3).+.tar.bz2"))'
elif [[ "$1" == "url_ver" ]]; then
# Note: Releases sometimes have hex-encoded ascii characters tacked on
# So version '2.0.0+' might need to be requested as '2.0.0%2B' since GitHub returns that as the download URL
echo "${allReleases}" | jq --arg VERSION "$VER" -r '.[] | .assets[] | .browser_download_url | select(test("PrusaSlicer-" + $VERSION + "linux64-.+.tar.bz2"))'
elif [[ "$1" == "name_ver" ]]; then
echo "${allReleases}" | jq --arg VERSION "$VER" -r '.[] | .assets[] | .name | select(test("PrusaSlicer-" + $VERSION + "\\+linux64-.+.tar.bz2"))'
fi

20
menu.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/ file:///usr/share/openbox/menu.xsd">
<menu id="root-menu" label="Openbox 3">
<item label="Prusaslicer">
<action name="Execute">
<execute>/slic3r/slic3r-dist/prusa-slicer</execute>
</action>
</item>
<item label="Terminal">
<action name="Execute">
<execute>/usr/bin/x-terminal-emulator</execute>
</action>
</item>
<item label="Htop">
<action name="Execute">
<execute>/usr/bin/x-terminal-emulator -e htop</execute>
</action>
</item>
</menu>
</openbox_menu>

29
supervisord.conf Normal file
View File

@ -0,0 +1,29 @@
[supervisord]
nodaemon=true
pidfile=/tmp/supervisord.pid
[program:x11]
priority=0
command=/usr/bin/Xtigervnc -desktop "Prusaslicer" -localhost -rfbport 5900 -SecurityTypes None -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -AcceptSetDesktopSize -SendCutText -AcceptCutText :0
autorestart=true
redirect_stderr=true
[program:easy-novnc]
priority=0
command=/usr/local/bin/easy-novnc --addr :8080 --host localhost --port 5900 --no-url-password --novnc-params "resize=remote"
autorestart=true
redirect_stderr=true
[program:openbox]
priority=1
command=/usr/bin/openbox
environment=DISPLAY=:0
autorestart=true
redirect_stderr=true
[program:prusaslicer]
priority=1
environment=DISPLAY=:0
command=/bin/bash -c '/slic3r/slic3r-dist/prusa-slicer'
autorestart=true
redirect_stderr=true