From 32588ed555a8fecec9f8bd9deff2580cc42a2458 Mon Sep 17 00:00:00 2001 From: oznu Date: Sat, 2 Sep 2017 00:09:42 +1000 Subject: [PATCH] first commit --- .gitignore | 1 + Dockerfile | 61 +++++++++++++++++++++++++ README.md | 19 ++++++++ root/app/guacamole/guacamole.properties | 7 +++ root/etc/cont-init.d/30-defaults.sh | 3 ++ root/etc/cont-init.d/40-postgres.sh | 11 +++++ root/etc/services.d/guacamole/run | 17 +++++++ root/etc/services.d/guacd/run | 4 ++ root/etc/services.d/postgres/run | 4 ++ 9 files changed, 127 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 root/app/guacamole/guacamole.properties create mode 100644 root/etc/cont-init.d/30-defaults.sh create mode 100644 root/etc/cont-init.d/40-postgres.sh create mode 100644 root/etc/services.d/guacamole/run create mode 100644 root/etc/services.d/guacd/run create mode 100644 root/etc/services.d/postgres/run diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04204c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9844702 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +FROM tomcat:7-jre8 + +ENV GUAC_VER=0.9.13-incubating \ + GUACAMOLE_HOME=/app/guacamole + +ENV PG_MAJOR=9.6 \ + PGDATA=/config/postgres \ + POSTGRES_USER=guacamole \ + POSTGRES_DB=guacamole_db + +# Apply the s6-overlay +RUN curl -SLO "https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz" \ + && tar -xzf s6-overlay-amd64.tar.gz -C / --exclude="./bin" --exclude="./sbin" \ + && tar -xzf s6-overlay-amd64.tar.gz -C /usr ./bin \ + && rm -rf s6-overlay-amd64.tar.gz \ + && mkdir -p ${GUACAMOLE_HOME} \ + ${GUACAMOLE_HOME}/lib \ + ${GUACAMOLE_HOME}/extensions + +WORKDIR ${GUACAMOLE_HOME} + +# Install dependencies +RUN apt-get update && apt-get install -y \ + libcairo2-dev libjpeg62-turbo-dev libpng-dev \ + libossp-uuid-dev libavcodec-dev libavutil-dev \ + libswscale-dev libfreerdp-dev libpango1.0-dev \ + libssh2-1-dev libtelnet-dev libvncserver-dev \ + libpulse-dev libssl-dev libvorbis-dev libwebp-dev \ + postgresql-${PG_MAJOR} \ + && rm -rf /var/lib/apt/lists/* + +# Install guacamole-server +RUN curl -SLO "https://sourceforge.net/projects/guacamole/files/current/source/guacamole-server-${GUAC_VER}.tar.gz" \ + && tar -xzf guacamole-server-${GUAC_VER}.tar.gz \ + && cd guacamole-server-${GUAC_VER} \ + && ./configure \ + && make \ + && make install \ + && cd .. \ + && rm -rf guacamole-server-${GUAC_VER}.tar.gz guacamole-server-${GUAC_VER} + +# Install guacamole-client and postgres auth adapter +RUN rm -rf ${CATALINA_HOME}/webapps/ROOT \ + && curl -SLo ${CATALINA_HOME}/webapps/ROOT.war "https://sourceforge.net/projects/guacamole/files/current/binary/guacamole-${GUAC_VER}.war" \ + && curl -SLo ${GUACAMOLE_HOME}/lib/postgresql-42.1.4.jar "https://jdbc.postgresql.org/download/postgresql-42.1.4.jar" \ + && curl -SLO https://sourceforge.net/projects/guacamole/files/current/extensions/guacamole-auth-jdbc-${GUAC_VER}.tar.gz \ + && tar -xzf guacamole-auth-jdbc-${GUAC_VER}.tar.gz \ + && cp -R guacamole-auth-jdbc-${GUAC_VER}/postgresql/guacamole-auth-jdbc-postgresql-0.9.13-incubating.jar ${GUACAMOLE_HOME}/extensions/ \ + && cp -R guacamole-auth-jdbc-${GUAC_VER}/postgresql/schema ${GUACAMOLE_HOME}/ \ + && rm -rf guacamole-auth-jdbc-${GUAC_VER} guacamole-auth-jdbc-${GUAC_VER}.tar.gz + +ENV PATH=/usr/lib/postgresql/${PG_MAJOR}/bin:$PATH +ENV GUACAMOLE_HOME=/config/guacamole + +WORKDIR /config + +RUN ldconfig + +COPY root / + +ENTRYPOINT [ "/init" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..d7f4ed7 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Docker Guacamole + +A Docker Container for [Apache Guacamole](https://guacamole.incubator.apache.org/), a client-less remote desktop gateway. It supports standard protocols like VNC, RDP, and SSH over HTML5. + +## Usage + +```shell +docker run \ + -p 8080:8080 \ + -v :/config \ + oznu/guacamole +``` + +## Parameters + +The parameters are split into two halves, separated by a colon, the left hand side representing the host and the right the container side. + +* `-p 8080:8080` - Binds the service to port 8080 on the Docker host, **required** +* `-v /config` - The config and database location, **required** diff --git a/root/app/guacamole/guacamole.properties b/root/app/guacamole/guacamole.properties new file mode 100644 index 0000000..8bdde65 --- /dev/null +++ b/root/app/guacamole/guacamole.properties @@ -0,0 +1,7 @@ +postgresql-hostname: localhost +postgresql-port: 5432 +postgresql-database: guacamole_db +postgresql-username: guacamole +postgresql-password: null + +enable-clipboard-integration: true diff --git a/root/etc/cont-init.d/30-defaults.sh b/root/etc/cont-init.d/30-defaults.sh new file mode 100644 index 0000000..8f7ec4e --- /dev/null +++ b/root/etc/cont-init.d/30-defaults.sh @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv sh + +cp -rn /app/guacamole /config diff --git a/root/etc/cont-init.d/40-postgres.sh b/root/etc/cont-init.d/40-postgres.sh new file mode 100644 index 0000000..2f75156 --- /dev/null +++ b/root/etc/cont-init.d/40-postgres.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv sh + +mkdir -p /config/postgres +chown postgres:postgres /config/postgres +chmod 0700 /config/postgres + +if [ -e /config/postgres/postgresql.conf ]; then + echo "Database already configured" +else + s6-setuidgid postgres initdb +fi diff --git a/root/etc/services.d/guacamole/run b/root/etc/services.d/guacamole/run new file mode 100644 index 0000000..70e5540 --- /dev/null +++ b/root/etc/services.d/guacamole/run @@ -0,0 +1,17 @@ +#!/usr/bin/with-contenv sh + +until pg_isready; do + echo "Waiting for postgres to come up..." + sleep 1 +done + +# Create database if it does not exist +psql -U postgres -lqt | cut -d \| -f 1 | grep -qw $POSTGRES_DB +if [ $? -ne 0 ]; then + createuser -U postgres $POSTGRES_USER + createdb -U postgres -O $POSTGRES_USER $POSTGRES_DB + cat /app/guacamole/schema/*.sql | psql -U $POSTGRES_USER -d $POSTGRES_DB -f - +fi + +echo "Starting guacamole client..." +s6-setuidgid root catalina.sh run diff --git a/root/etc/services.d/guacd/run b/root/etc/services.d/guacd/run new file mode 100644 index 0000000..da9e903 --- /dev/null +++ b/root/etc/services.d/guacd/run @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv sh + +echo "Starting guacamole guacd..." +s6-setuidgid root guacd -f diff --git a/root/etc/services.d/postgres/run b/root/etc/services.d/postgres/run new file mode 100644 index 0000000..298dc99 --- /dev/null +++ b/root/etc/services.d/postgres/run @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv sh + +echo "Starting postgres..." +s6-setuidgid postgres postgres