diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2799dbf --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +#Ignore the git and cache folders +.git +.cache + +#Ingore all markdown and class files +*.md +**/*.class + +#Ignore tmp +tmp \ No newline at end of file diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml index 7047d55..35319c1 100644 --- a/.github/workflows/docker-image-dev.yml +++ b/.github/workflows/docker-image-dev.yml @@ -56,7 +56,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . - platforms: linux/amd64,linux/arm64,linux/ppc64le + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.guac.outputs.tags }} labels: ${{ steps.guac.outputs.labels }} diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 1e4af2e..c453d06 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -51,7 +51,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . - platforms: linux/amd64,linux/arm64,linux/ppc64le + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.guac.outputs.tags }} labels: ${{ steps.guac.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9bdc842..f1d8458 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Select BASE -FROM tomcat:9-jdk8 +FROM tomcat:8.5-jdk8-openjdk-slim-bullseye ARG APPLICATION="guacamole" -ARG BUILD_RFC3339="2023-03-16T15:00:00Z" +ARG BUILD_RFC3339="2023-03-17T15:00:00Z" ARG REVISION="local" ARG DESCRIPTION="Guacamole 1.5.0" ARG PACKAGE="MaxWaldorf/guacamole" @@ -32,9 +32,7 @@ ENV \ REVISION="${REVISION}" \ DESCRIPTION="${DESCRIPTION}" \ PACKAGE="${PACKAGE}" \ - VERSION="${VERSION}" \ - S6_OVERLAY_VERSION="${S6_OVERLAY_VERSION}" \ - S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 + VERSION="${VERSION}" ENV \ GUAC_VER=${VERSION} \ @@ -44,67 +42,48 @@ ENV \ POSTGRES_USER=guacamole \ POSTGRES_DB=guacamole_db -# Set working DIR +#Set working DIR +RUN mkdir -p ${GUACAMOLE_HOME}/{extensions,extensions-available,lib} WORKDIR ${GUACAMOLE_HOME} -# Display variables (Test) -RUN echo "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" +# Add support for bullseye-backports +RUN echo "deb http://deb.debian.org/debian bullseye-backports main contrib non-free" >> /etc/apt/sources.list -# Add support for Postgresql 13 -RUN apt-get update && apt-get install -y curl gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null -RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list +# Add essential utils +RUN set -xe && \ + apt-get update && apt-get install -y vim xz-utils \ + curl gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates -# Install initial components -RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y xz-utils curl postgresql-${PG_MAJOR} ghostscript - -#Add Fonts as requested by users -RUN apt-get install -y fonts-spleen fonty-rg +# Add Postgresql +RUN set -xe && \ +apt-get update && apt-get install -y postgresql-${PG_MAJOR} # Install dependencies -RUN apt-get install -y \ +RUN set -xe && \ + apt-get -t bullseye-backports install -y \ build-essential \ - libcairo2-dev libjpeg-turbo8-dev libpng-dev libtool-bin uuid-dev libossp-uuid-dev \ + ghostscript fonts-spleen fonty-rg\ + libcairo2-dev libjpeg62-turbo-dev libpng-dev libtool-bin uuid-dev libossp-uuid-dev \ libavcodec-dev libavformat-dev libavutil-dev libswscale-dev \ freerdp2-dev libpango1.0-dev libssh2-1-dev libtelnet-dev libvncserver-dev libwebsockets-dev libpulse-dev libssl-dev libvorbis-dev libwebp-dev # Apply the s6-overlay -RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; \ - then S6_ARCH=x86_64; \ -elif [ "$TARGETPLATFORM" = "linux/arm/v6" ]; \ - then S6_ARCH=arm; \ -elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; \ - then S6_ARCH=armhf; \ -elif [ "$TARGETPLATFORM" = "linux/arm64" ]; \ - then S6_ARCH=aarch64; \ -elif [ "$TARGETPLATFORM" = "linux/ppc64le" ]; \ - then S6_ARCH=powerpc64le; \ -else S6_ARCH=x86_64; \ -fi \ - && curl -SL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" > /tmp/s6-overlay-noarch.tar.xz \ - && tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \ - && curl -SL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz" > /tmp/s6-overlay-${S6_ARCH}.tar.xz \ - && tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz \ - && curl -SL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz" > /tmp/s6-overlay-symlinks-noarch.tar.xz \ - && tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz - #&& curl -SL "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/syslogd-overlay-noarch.tar.xz" > /tmp/syslogd-overlay-noarch.tar.xz \ - #&& tar -C / -Jxpf /tmp/syslogd-overlay-noarch.tar.xz - -# Create Required Directories for Guacamole -RUN mkdir -p ${GUACAMOLE_HOME} \ - ${GUACAMOLE_HOME}/lib \ - ${GUACAMOLE_HOME}/extensions +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then ARCH=amd64; elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH=aarch64; elif [ "$TARGETPLATFORM" = "linux/ppc64le" ]; then ARCH=powerpc64le; else ARCH=amd64; fi \ + && curl -SLO "https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-${ARCH}.tar.gz" \ + && tar -xzf s6-overlay-${ARCH}.tar.gz -C / \ + && tar -xzf s6-overlay-${ARCH}.tar.gz -C /usr ./bin \ + && rm -rf s6-overlay-${ARCH}.tar.gz # Install guacamole-server RUN curl -SLO "http://apache.org/dyn/closer.cgi?action=download&filename=guacamole/${GUAC_VER}/source/guacamole-server-${GUAC_VER}.tar.gz" \ - && tar -xzf guacamole-server-${GUAC_VER}.tar.gz \ - && cd guacamole-server-${GUAC_VER} \ - && ./configure \ - && make -j$(getconf _NPROCESSORS_ONLN) \ - && make install \ - && cd .. \ - && rm -rf guacamole-server-${GUAC_VER}.tar.gz guacamole-server-${GUAC_VER} \ - && ldconfig +&& tar -xzf ${GUACAMOLE_HOME}/guacamole-server-${GUAC_VER}.tar.gz \ +&& cd ${GUACAMOLE_HOME}/guacamole-server-${GUAC_VER} \ +&& ./configure \ +&& make -j$(getconf _NPROCESSORS_ONLN) \ +&& make install \ +&& cd .. \ +&& rm -rf guacamole-server-${GUAC_VER}.tar.gz guacamole-server-${GUAC_VER} \ +&& ldconfig # Install guacamole-client and postgres auth adapter RUN set -x \ @@ -116,8 +95,6 @@ RUN set -x \ ################################# EXTENSIONS ################################## ############################################################################### -RUN mkdir ${GUACAMOLE_HOME}/extensions-available - # Download all extensions RUN set -xe \ && for ext_name in auth-duo auth-header auth-jdbc auth-json auth-ldap auth-quickconnect auth-sso auth-totp vault history-recording-storage; do \ @@ -159,8 +136,10 @@ RUN set -xe \ ############################################################################### ############################################################################### -# Purge Build packages -RUN apt-get purge -y build-essential \ +# Purge BUild packages +RUN apt-get dist-upgrade -y +RUN apt-get purge -y build-essential xz-utils\ + && apt-get autoremove -y && apt-get autoclean \ && rm -rf /var/lib/apt/lists/* @@ -172,6 +151,4 @@ WORKDIR /config COPY rootfs / -EXPOSE 8080 - ENTRYPOINT [ "/init" ] diff --git a/rootfs/etc/cont-init.d/30-defaults.sh b/rootfs/etc/cont-init.d/30-defaults.sh index c83c2d6..464083e 100755 --- a/rootfs/etc/cont-init.d/30-defaults.sh +++ b/rootfs/etc/cont-init.d/30-defaults.sh @@ -1,4 +1,4 @@ -#!/command/with-contenv bash +#!/usr/bin/with-contenv sh cp -rn /app/guacamole /config mkdir -p /root/.config/freerdp/known_hosts diff --git a/rootfs/etc/cont-init.d/40-postgres.sh b/rootfs/etc/cont-init.d/40-postgres.sh index fa1bee6..9b766fa 100755 --- a/rootfs/etc/cont-init.d/40-postgres.sh +++ b/rootfs/etc/cont-init.d/40-postgres.sh @@ -1,4 +1,4 @@ -#!/command/with-contenv bash +#!/usr/bin/with-contenv sh mkdir -p /config/postgres mkdir -p /var/run/postgresql diff --git a/rootfs/etc/cont-init.d/50-extensions.sh b/rootfs/etc/cont-init.d/50-extensions old mode 100755 new mode 100644 similarity index 95% rename from rootfs/etc/cont-init.d/50-extensions.sh rename to rootfs/etc/cont-init.d/50-extensions index bd41c6f..c5ec114 --- a/rootfs/etc/cont-init.d/50-extensions.sh +++ b/rootfs/etc/cont-init.d/50-extensions @@ -1,4 +1,4 @@ -#!/command/with-contenv bash +#!/usr/bin/with-contenv sh # clean up extensions for i in auth-ldap auth-duo auth-header auth-cas auth-openid auth-quickconnect auth-totp; do diff --git a/rootfs/etc/services.d/guacamole/run b/rootfs/etc/services.d/guacamole/run index fdf4889..ec82214 100755 --- a/rootfs/etc/services.d/guacamole/run +++ b/rootfs/etc/services.d/guacamole/run @@ -1,4 +1,4 @@ -#!/command/with-contenv bash +#!/usr/bin/with-contenv sh until pg_isready; do echo "Waiting for postgres to come up..." @@ -14,14 +14,16 @@ if [ $? -ne 0 ]; then echo "$GUAC_VER" > /config/.database-version /etc/cont-init.d/30-defaults.sh - /etc/cont-init.d/50-extensions.sh + /etc/cont-init.d/50-extensions + else if [ "$(cat /config/.database-version)" != "$GUAC_VER" ]; then cat /app/guacamole/schema/upgrade/upgrade-pre-$GUAC_VER.sql | psql -U $POSTGRES_USER -d $POSTGRES_DB -f - echo "$GUAC_VER" > /config/.database-version /etc/cont-init.d/30-defaults.sh - /etc/cont-init.d/50-extensions.sh + /etc/cont-init.d/50-extensions + fi fi diff --git a/rootfs/etc/services.d/guacd/run b/rootfs/etc/services.d/guacd/run index 249f120..43f60e8 100755 --- a/rootfs/etc/services.d/guacd/run +++ b/rootfs/etc/services.d/guacd/run @@ -1,4 +1,4 @@ -#!/command/with-contenv bash +#!/usr/bin/with-contenv sh echo "Starting guacamole guacd..." s6-setuidgid root guacd -b 0.0.0.0 -f diff --git a/rootfs/etc/services.d/postgres/run b/rootfs/etc/services.d/postgres/run index 96eca9a..298dc99 100755 --- a/rootfs/etc/services.d/postgres/run +++ b/rootfs/etc/services.d/postgres/run @@ -1,4 +1,4 @@ -#!/command/with-contenv bash +#!/usr/bin/with-contenv sh echo "Starting postgres..." s6-setuidgid postgres postgres