diff --git a/.gitignore b/.gitignore index 6185788..43cb8c9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ __pycache__/ build/ dist/ +docker/data/ *.egg-info/ node_modules/ diff --git a/README.md b/README.md index 9973f20..2f2bb42 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ Oracle Java image yourself: ``` 2. Visit [the Java download page](https://www.java.com/en/download/manual.jsp) and get the *Linux x64* tar archive of - Oracle Java version `8u251`. Save it to the `docker` subdirectory of the previously cloned repository as + Oracle Java version `8u251`. Save it to the `docker/data` subdirectory of the previously cloned repository as `jre-8u251-linux-x64.tar.gz`. If you would like to also use Oracle Java 7, get `jre-7u80-linux-x64.tar.gz` from [Oracle's Java archive](https://www.oracle.com/java/technologies/javase/javase7-archive-downloads.html) (this requires an free Oracle account). diff --git a/docker/Dockerfile_html5 b/docker/Dockerfile_html5 index 250f61b..9c7196b 100644 --- a/docker/Dockerfile_html5 +++ b/docker/Dockerfile_html5 @@ -1,11 +1,19 @@ FROM node:14 LABEL maintainer="Maximilian Heuwes " +# Set packages from deb.debian.com to archive.debian.com +COPY ./config/buster-sources.list /etc/apt/sources.list +RUN apt-get update && \ + apt-get install -y wget && \ + wget -O /tmp/debian-keyring.deb http://http.us.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2025.1_all.deb && \ + dpkg -i /tmp/debian-keyring.deb && \ + rm /tmp/debian-keyring.deb + RUN apt-get update && \ apt-get install -y --no-install-recommends ca-certificates curl net-tools procps python-numpy \ python-pip python-pyquery python-setuptools python-wheel tar && \ rm -rf /var/lib/apt/lists/* && \ - pip install future requests && \ + pip install future requests requests_file && \ mkdir /usr/local/kvm-html5/ COPY kvm-html5/package*.json /usr/local/kvm-html5/ diff --git a/docker/Dockerfile_openjdk-7 b/docker/Dockerfile_openjdk-7 index 94e20cd..8b75a36 100644 --- a/docker/Dockerfile_openjdk-7 +++ b/docker/Dockerfile_openjdk-7 @@ -1,9 +1,16 @@ FROM debian:jessie LABEL maintainer="Ingo Meyer " -# Install needed packages and Java dependencies (second `apt-get install` call) +# Set packages from deb.debian.com to archive.debian.com +COPY ./config/jessie-sources.list /etc/apt/sources.list RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ + apt-get install -y wget && \ + wget -O /tmp/debian-keyring.deb http://http.us.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2025.1_all.deb && \ + dpkg -i /tmp/debian-keyring.deb && \ + rm /tmp/debian-keyring.deb + +# Install needed packages and Java dependencies (second `apt-get install` call) +RUN apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ python-pip python-pyquery python-wheel supervisor tar x11vnc xvfb && \ apt-get install -y --no-install-recommends ca-certificates-java initscripts java-common libasound2 \ libatk-wrapper-java-jni libatk1.0-0 libc6 libcairo2 libcups2 \ @@ -16,7 +23,7 @@ RUN apt-get update && \ # Add support for asian characters apt-get install -y --no-install-recommends fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho \ fonts-ipafont-gothic fonts-unfonts-core && \ - pip install future requests 'websockify<0.10' && \ + pip install future requests requests_file 'websockify<0.10' && \ rm -rf /var/lib/apt/lists/* RUN for java_version in "7u51" "7u79" "7u181"; do \ @@ -60,7 +67,7 @@ COPY supervisord_openjdk-7.conf /etc/supervisor/conf.d/supervisord.conf WORKDIR /root/ -ENV DISPLAY :0 +ENV DISPLAY=:0 EXPOSE 8080 ENTRYPOINT ["/usr/local/bin/docker-entrypoint"] diff --git a/docker/Dockerfile_openjdk-8 b/docker/Dockerfile_openjdk-8 index a64e88a..c0d2a02 100644 --- a/docker/Dockerfile_openjdk-8 +++ b/docker/Dockerfile_openjdk-8 @@ -1,9 +1,16 @@ FROM debian:stretch LABEL maintainer="Ingo Meyer " -# Install needed packages and Java dependencies (second `apt-get install` call) +# Set packages from deb.debian.com to archive.debian.com +COPY ./config/stretch-sources.list /etc/apt/sources.list RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ + apt-get install -y wget && \ + wget -O /tmp/debian-keyring.deb http://http.us.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2025.1_all.deb && \ + dpkg -i /tmp/debian-keyring.deb && \ + rm /tmp/debian-keyring.deb + +# Install needed packages and Java dependencies (second `apt-get install` call) +RUN apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ python-pip python-pyquery python-setuptools python-wheel supervisor tar \ x11vnc xvfb && \ apt-get install -y --no-install-recommends adwaita-icon-theme ca-certificates ca-certificates-java \ @@ -40,7 +47,7 @@ RUN apt-get update && \ # Add support for asian characters apt-get install -y --no-install-recommends fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho \ fonts-ipafont-gothic fonts-unfonts-core && \ - pip install future requests 'websockify<0.10' && \ + pip install future requests requests_file 'websockify<0.10' && \ rm -rf /var/lib/apt/lists/* RUN for java_version in "8u91" "8u242"; do \ @@ -76,7 +83,7 @@ COPY supervisord_openjdk-8.conf /etc/supervisor/conf.d/supervisord.conf WORKDIR /root/ -ENV DISPLAY :0 +ENV DISPLAY=:0 EXPOSE 8080 ENTRYPOINT ["/usr/local/bin/docker-entrypoint"] diff --git a/docker/Dockerfile_oraclejre-7 b/docker/Dockerfile_oraclejre-7 index 77a602b..148c9df 100644 --- a/docker/Dockerfile_oraclejre-7 +++ b/docker/Dockerfile_oraclejre-7 @@ -1,9 +1,16 @@ FROM debian:stretch LABEL maintainer="Ingo Meyer " -# Install needed packages and Java dependencies (second `apt-get install` call) +# Set packages from deb.debian.com to archive.debian.com +COPY ./config/stretch-sources.list /etc/apt/sources.list RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ + apt-get install -y wget && \ + wget -O /tmp/debian-keyring.deb http://http.us.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2025.1_all.deb && \ + dpkg -i /tmp/debian-keyring.deb && \ + rm /tmp/debian-keyring.deb + +# Install needed packages and Java dependencies (second `apt-get install` call) +RUN apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ python-pip python-pyquery python-setuptools python-wheel supervisor tar \ x11vnc xvfb && \ apt-get install -y --no-install-recommends adwaita-icon-theme ca-certificates ca-certificates-java \ @@ -40,7 +47,7 @@ RUN apt-get update && \ # Add support for asian characters apt-get install -y --no-install-recommends fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho \ fonts-ipafont-gothic fonts-unfonts-core && \ - pip install future requests 'websockify<0.10' && \ + pip install future requests requests_file 'websockify<0.10' && \ rm -rf /var/lib/apt/lists/* RUN NOVNC_VERSION="1.1.0" && \ @@ -49,7 +56,7 @@ RUN NOVNC_VERSION="1.1.0" && \ ln -s "/opt/noVNC-${NOVNC_VERSION}/utils/launch.sh" /usr/local/bin/launch_novnc && \ rm -f /tmp/novnc.tar.gz -COPY jre-7u80-linux-x64.tar.gz /opt/java_packages/7u80/jre-7u80-linux-x64.tar.gz +COPY data/jre-7u80-linux-x64.tar.gz /opt/java_packages/7u80/jre-7u80-linux-x64.tar.gz COPY entrypoint.sh /usr/local/bin/docker-entrypoint COPY get_java_viewer.py /usr/local/bin/get_java_viewer @@ -58,7 +65,7 @@ COPY supervisord_oraclejre-7.conf /etc/supervisor/conf.d/supervisord.conf WORKDIR /root/ -ENV DISPLAY :0 +ENV DISPLAY=:0 EXPOSE 8080 ENTRYPOINT ["/usr/local/bin/docker-entrypoint"] diff --git a/docker/Dockerfile_oraclejre-8 b/docker/Dockerfile_oraclejre-8 index 71268aa..d0b7a3d 100644 --- a/docker/Dockerfile_oraclejre-8 +++ b/docker/Dockerfile_oraclejre-8 @@ -1,9 +1,16 @@ FROM debian:stretch LABEL maintainer="Ingo Meyer " -# Install needed packages and Java dependencies (second `apt-get install` call) +# Set packages from deb.debian.com to archive.debian.com +COPY ./config/stretch-sources.list /etc/apt/sources.list RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ + apt-get install -y wget && \ + wget -O /tmp/debian-keyring.deb http://http.us.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2025.1_all.deb && \ + dpkg -i /tmp/debian-keyring.deb && \ + rm /tmp/debian-keyring.deb + +# Install needed packages and Java dependencies (second `apt-get install` call) +RUN apt-get install -y --no-install-recommends ca-certificates curl eterm fluxbox net-tools procps python-numpy \ python-pip python-pyquery python-setuptools python-wheel supervisor tar \ x11vnc xvfb && \ apt-get install -y --no-install-recommends adwaita-icon-theme ca-certificates ca-certificates-java \ @@ -40,7 +47,7 @@ RUN apt-get update && \ # Add support for asian characters apt-get install -y --no-install-recommends fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho \ fonts-ipafont-gothic fonts-unfonts-core && \ - pip install future requests 'websockify<0.10' && \ + pip install future requests requests_file 'websockify<0.10' && \ rm -rf /var/lib/apt/lists/* RUN NOVNC_VERSION="1.1.0" && \ @@ -49,7 +56,7 @@ RUN NOVNC_VERSION="1.1.0" && \ ln -s "/opt/noVNC-${NOVNC_VERSION}/utils/launch.sh" /usr/local/bin/launch_novnc && \ rm -f /tmp/novnc.tar.gz -COPY jre-8u251-linux-x64.tar.gz /opt/java_packages/8u251/jre-8u251-linux-x64.tar.gz +COPY data/jre-8u251-linux-x64.tar.gz /opt/java_packages/8u251/jre-8u251-linux-x64.tar.gz COPY entrypoint.sh /usr/local/bin/docker-entrypoint COPY get_java_viewer.py /usr/local/bin/get_java_viewer @@ -58,7 +65,7 @@ COPY supervisord_oraclejre-8.conf /etc/supervisor/conf.d/supervisord.conf WORKDIR /root/ -ENV DISPLAY :0 +ENV DISPLAY=:0 EXPOSE 8080 ENTRYPOINT ["/usr/local/bin/docker-entrypoint"] diff --git a/docker/Makefile b/docker/Makefile index 528082d..bcde405 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -15,18 +15,19 @@ build-openjdk: done build-oracle: - @if [[ -f "jre-7u80-linux-x64.tar.gz" ]]; then \ + @if [ -f "data/jre-7u80-linux-x64.tar.gz" ]; then \ docker build -t "sciapp/nojava-ipmi-kvm:latest-oraclejre-7" -f "Dockerfile_oraclejre-7" .; \ - if [[ "$$(git symbolic-ref -q HEAD)" == "refs/heads/master" ]]; then \ + if [ "$$(git symbolic-ref -q HEAD)" = "refs/heads/master" ]; then \ docker tag "sciapp/nojava-ipmi-kvm:latest-oraclejre-7" \ "sciapp/nojava-ipmi-kvm:v$(PACKAGE_VERSION)-oraclejre-7"; \ fi; \ else \ >&2 echo "Please download \"jre-7u80-linux-x64.tar.gz\" to build an Oracle Java 7 docker image."; \ - fi; \ - if [[ -f "jre-8u251-linux-x64.tar.gz" ]]; then \ + fi; + + @if [ -f "data/jre-8u251-linux-x64.tar.gz" ]; then \ docker build -t "sciapp/nojava-ipmi-kvm:latest-oraclejre-8" -f "Dockerfile_oraclejre-8" .; \ - if [[ "$$(git symbolic-ref -q HEAD)" == "refs/heads/master" ]]; then \ + if [ "$$(git symbolic-ref -q HEAD)" = "refs/heads/master" ]; then \ docker tag "sciapp/nojava-ipmi-kvm:latest-oraclejre-8" \ "sciapp/nojava-ipmi-kvm:v$(PACKAGE_VERSION)-oraclejre-8"; \ fi; \ diff --git a/docker/config/buster-sources.list b/docker/config/buster-sources.list new file mode 100644 index 0000000..52fc13b --- /dev/null +++ b/docker/config/buster-sources.list @@ -0,0 +1,2 @@ +deb [trusted=yes] http://archive.debian.org/debian buster main +deb [trusted=yes] http://archive.debian.org/debian-security buster/updates main diff --git a/docker/config/jessie-sources.list b/docker/config/jessie-sources.list new file mode 100644 index 0000000..785de9b --- /dev/null +++ b/docker/config/jessie-sources.list @@ -0,0 +1,2 @@ +deb [trusted=yes] http://archive.debian.org/debian jessie main +deb [trusted=yes] http://archive.debian.org/debian-security jessie/updates main diff --git a/docker/config/stretch-sources.list b/docker/config/stretch-sources.list new file mode 100644 index 0000000..9ae3d3d --- /dev/null +++ b/docker/config/stretch-sources.list @@ -0,0 +1,2 @@ +deb [trusted=yes] http://archive.debian.org/debian stretch main +deb [trusted=yes] http://archive.debian.org/debian-security stretch/updates main diff --git a/docker/data/.gitkeep b/docker/data/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/docker/data/.gitkeep @@ -0,0 +1 @@ + diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index c404cb0..6a2c574 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,6 +1,9 @@ #!/bin/bash -read -r -s PASSWD +if [[ ! -v PASSWD ]]; then + read -r -s PASSWD +fi + echo "${PASSWD}" | /usr/local/bin/get_java_viewer -o /tmp/launch.jnlp "$@" return_code="$?" if [[ "${return_code}" -ne 0 ]]; then diff --git a/docker/get_java_viewer.py b/docker/get_java_viewer.py index cddf107..b41303b 100755 --- a/docker/get_java_viewer.py +++ b/docker/get_java_viewer.py @@ -21,6 +21,7 @@ import urllib.parse import sys import json +from requests_file import FileAdapter try: from typing import Any, Dict, Optional, Text # noqa: F401 # pylint: disable=unused-import @@ -259,6 +260,7 @@ def get_java_viewer( base_url = "https://{}".format(hostname) download_url = urllib.parse.urljoin(base_url, download_endpoint) session = requests.Session() + session.mount("file://", FileAdapter()) def do_login(session_cookie_key): # type: (Optional[Text]) -> None @@ -297,6 +299,9 @@ def do_login(session_cookie_key): print(json.dumps({"cookies": session.cookies.get_dict(), "headers": dict(session.headers)})) return + if download_endpoint.startswith('file://'): + download_url = download_endpoint + # Download the kvm viewer with the previous created session response = session.get(download_url, verify=ssl_verify) if response.status_code != 200: diff --git a/setup.py b/setup.py index aef3e7a..575bb77 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def get_long_description_from_readme(readme_filename="README.md"): version=version, packages=find_packages(), python_requires="~=3.5", - install_requires=["requests", "yacl", "pyyaml"], + install_requires=["requests", "yacl", "pyyaml", "requests_file"], extras_require={"GUI": ["PyQt5>=5.12", "PyQtWebEngine>=5.12"]}, entry_points={"console_scripts": ["nojava-ipmi-kvm = nojava_ipmi_kvm.cli:main"]}, author="Ingo Meyer",