Skip to content

Commit d6ff746

Browse files
authored
GUACAMOLE-374: Merge generalize Docker image to automatically map environment variables to properties.
2 parents 8311161 + 1b271a2 commit d6ff746

21 files changed

+1244
-1476
lines changed

Dockerfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,24 @@ ENV \
6161

6262
# Add configuration scripts
6363
COPY guacamole-docker/bin/ /opt/guacamole/bin/
64+
COPY guacamole-docker/build.d/ /opt/guacamole/build.d/
65+
COPY guacamole-docker/entrypoint.d/ /opt/guacamole/entrypoint.d/
66+
COPY guacamole-docker/environment/ /opt/guacamole/environment/
6467

6568
# Copy source to container for sake of build
6669
COPY . "$BUILD_DIR"
6770

6871
# Run the build itself
6972
RUN /opt/guacamole/bin/build-guacamole.sh "$BUILD_DIR" /opt/guacamole
7073

74+
RUN rm -rf /opt/guacamole/build.d /opt/guacamole/bin/build-guacamole.sh
75+
7176
# For the runtime image, we start with the official Tomcat distribution
7277
FROM tomcat:${TOMCAT_VERSION}-${TOMCAT_JRE}
7378

74-
# Install XMLStarlet for server.xml alterations and unzip for LOGBACK_LEVEL case
79+
# Install XMLStarlet for server.xml alterations
7580
RUN apt-get update -qq \
76-
&& apt-get install -y xmlstarlet unzip\
81+
&& apt-get install -y xmlstarlet \
7782
&& rm -rf /var/lib/apt/lists/*
7883

7984
# This is where the build artifacts go in the runtime image
@@ -91,6 +96,11 @@ RUN useradd --system --create-home --shell /usr/sbin/nologin --uid $UID --gid $G
9196
# Run with user guacamole
9297
USER guacamole
9398

99+
# Environment variable defaults
100+
ENV BAN_ENABLED=true \
101+
ENABLE_FILE_ENVIRONMENT_PROPERTIES=true \
102+
GUACAMOLE_HOME=/etc/guacamole
103+
94104
# Start Guacamole under Tomcat, listening on 0.0.0.0:8080
95105
EXPOSE 8080
96-
CMD ["/opt/guacamole/bin/start.sh" ]
106+
CMD ["/opt/guacamole/bin/entrypoint.sh" ]
Lines changed: 24 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh -e
1+
#!/bin/bash -e
22
#
33
# Licensed to the Apache Software Foundation (ASF) under one
44
# or more contributor license agreements. See the NOTICE file
@@ -23,10 +23,15 @@
2323
##
2424
## Builds Guacamole, saving "guacamole.war" and all applicable extension .jars
2525
## using the guacamole-client source contained within the given directory.
26-
## Extension files will be grouped by their associated type, with all MySQL
27-
## files being placed within the "mysql/" subdirectory of the destination, all
28-
## PostgreSQL files being placed within the "postgresql/" subdirectory of the
29-
## destination, etc.
26+
## Extension files will be grouped by their associated type, identical to
27+
## extracting the .tar.gz files included with each Guacamole release except
28+
## that version numbers are stripped from directory and .jar file names.
29+
##
30+
## The build process is split across multiple scripts within the
31+
## /opt/guacamole/build.d directory. Additional steps may be added to the
32+
## build process by adding .sh scripts to this directory. Any such scripts MUST
33+
## be shell scripts ending with a ".sh" extension and MUST be written for bash
34+
## (the shell used by this entrypoint).
3035
##
3136
## @param BUILD_DIR
3237
## The directory which currently contains the guacamole-client source and
@@ -39,164 +44,21 @@
3944
## extension type.
4045
##
4146

47+
##
48+
## The directory which currently contains the guacamole-client source and in
49+
## which the build should be performed.
50+
##
4251
BUILD_DIR="$1"
43-
DESTINATION="$2"
44-
45-
#
46-
# Create destination, if it does not yet exist
47-
#
48-
49-
mkdir -p "$DESTINATION"
50-
51-
#
52-
# Build guacamole.war and all extensions
53-
#
54-
55-
cd "$BUILD_DIR"
56-
57-
#
58-
# Run the maven build, applying any arbitrary provided maven arguments.
59-
#
60-
61-
mvn $MAVEN_ARGUMENTS package
62-
63-
#
64-
# Copy guacamole.war to destination
65-
#
66-
67-
cp guacamole/target/*.war "$DESTINATION/guacamole.war"
68-
69-
#
70-
# Copy JDBC auth extensions and SQL scripts
71-
#
72-
73-
tar -xzf extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-dist/target/*.tar.gz \
74-
-C "$DESTINATION" \
75-
--wildcards \
76-
--no-anchored \
77-
--strip-components=1 \
78-
"*.jar" \
79-
"*.sql"
80-
81-
#
82-
# Download MySQL JDBC driver
83-
#
84-
85-
echo "Downloading MySQL Connector/J ..."
86-
curl -L "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-$MYSQL_JDBC_VERSION.tar.gz" | \
87-
tar -xz \
88-
-C "$DESTINATION/mysql/" \
89-
--wildcards \
90-
--no-anchored \
91-
--no-wildcards-match-slash \
92-
--strip-components=1 \
93-
"mysql-connector-*.jar"
94-
95-
#
96-
# Download PostgreSQL JDBC driver
97-
#
98-
99-
echo "Downloading PostgreSQL JDBC driver ..."
100-
curl -L "https://jdbc.postgresql.org/download/postgresql-$PGSQL_JDBC_VERSION.jar" \
101-
> "$DESTINATION/postgresql/postgresql-$PGSQL_JDBC_VERSION.jar"
102-
103-
#
104-
# Copy SSO auth extensions
105-
#
106-
107-
tar -xzf extensions/guacamole-auth-sso/modules/guacamole-auth-sso-dist/target/*.tar.gz \
108-
-C "$DESTINATION" \
109-
--wildcards \
110-
--no-anchored \
111-
--strip-components=1 \
112-
"*.jar"
11352

114-
#
115-
# Download SQL Server JDBC driver
116-
#
117-
118-
echo "Downloading SQL Server JDBC driver ..."
119-
curl -L "https://github.com/microsoft/mssql-jdbc/releases/download/v$MSSQL_JDBC_VERSION/mssql-jdbc-$MSSQL_JDBC_VERSION.jre8.jar" \
120-
> "$DESTINATION/sqlserver/mssql-jdbc-$MSSQL_JDBC_VERSION.jre8.jar" \
121-
122-
#
123-
# Copy LDAP auth extension and schema modifications
124-
#
125-
126-
mkdir -p "$DESTINATION/ldap"
127-
tar -xzf extensions/guacamole-auth-ldap/target/*.tar.gz \
128-
-C "$DESTINATION/ldap" \
129-
--wildcards \
130-
--no-anchored \
131-
--xform="s#.*/##" \
132-
"*.jar" \
133-
"*.ldif"
134-
135-
#
136-
# Copy Radius auth extension if it was build
137-
#
138-
139-
if [ -f extensions/guacamole-auth-radius/target/guacamole-auth-radius*.jar ]; then
140-
mkdir -p "$DESTINATION/radius"
141-
cp extensions/guacamole-auth-radius/target/guacamole-auth-radius*.jar "$DESTINATION/radius"
142-
fi
143-
144-
#
145-
# Copy TOTP auth extension if it was built
146-
#
147-
148-
if [ -f extensions/guacamole-auth-totp/target/guacamole-auth-totp*.jar ]; then
149-
mkdir -p "$DESTINATION/totp"
150-
cp extensions/guacamole-auth-totp/target/guacamole-auth-totp*.jar "$DESTINATION/totp"
151-
fi
152-
153-
#
154-
# Copy Duo auth extension if it was built
155-
#
156-
157-
if [ -f extensions/guacamole-auth-duo/target/*.tar.gz ]; then
158-
mkdir -p "$DESTINATION/duo"
159-
tar -xzf extensions/guacamole-auth-duo/target/*.tar.gz \
160-
-C "$DESTINATION/duo/" \
161-
--wildcards \
162-
--no-anchored \
163-
--no-wildcards-match-slash \
164-
--strip-components=1 \
165-
"*.jar"
166-
fi
167-
168-
#
169-
# Copy header auth extension if it was built
170-
#
171-
172-
if [ -f extensions/guacamole-auth-header/target/guacamole-auth-header*.jar ]; then
173-
mkdir -p "$DESTINATION/header"
174-
cp extensions/guacamole-auth-header/target/guacamole-auth-header*.jar "$DESTINATION/header"
175-
fi
176-
177-
#
178-
# Copy json auth extension if it was built
179-
#
180-
181-
if [ -f extensions/guacamole-auth-json/target/guacamole-auth-json*.jar ]; then
182-
mkdir -p "$DESTINATION/json"
183-
cp extensions/guacamole-auth-json/target/guacamole-auth-json*.jar "$DESTINATION/json"
184-
fi
185-
186-
#
187-
# Copy automatic brute-force banning auth extension if it was built
188-
#
189-
190-
if [ -f extensions/guacamole-auth-ban/target/guacamole-auth-ban*.jar ]; then
191-
mkdir -p "$DESTINATION/ban"
192-
cp extensions/guacamole-auth-ban/target/guacamole-auth-ban*.jar "$DESTINATION/ban"
193-
fi
53+
##
54+
## The directory to save guacamole.war within, along with all extension .jars.
55+
## Note that this script will create extension-specific subdirectories within
56+
## this directory, and files will thus be grouped by extension type.
57+
##
58+
DESTINATION="$2"
19459

195-
#
196-
# Copy history recording storage extension if it was built
197-
#
60+
# Run all scripts within the "build.d" directory
61+
for SCRIPT in /opt/guacamole/build.d/*.sh; do
62+
source "$SCRIPT"
63+
done
19864

199-
if [ -f extensions/guacamole-history-recording-storage/target/guacamole-history-recording-storage*.jar ]; then
200-
mkdir -p "$DESTINATION/recordings"
201-
cp extensions/guacamole-history-recording-storage/target/guacamole-history-recording-storage*.jar "$DESTINATION/recordings"
202-
fi

guacamole-docker/bin/entrypoint.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash -e
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
##
22+
## @fn entrypoint.sh
23+
##
24+
## (Re-)configures the Apache Guacamole web application based on the values of
25+
## environment variables, deploys the web application beneath a bundled copy of
26+
## Apache Tomcat, and starts Tomcat.
27+
##
28+
## The startup process is split across multiple scripts within the
29+
## /opt/guacamole/entrypoint.d directory. Additional steps may be added to the
30+
## startup process by adding .sh scripts to this directory. Any such scripts
31+
## MUST be shell scripts ending with a ".sh" extension and MUST be written for
32+
## bash (the shell used by this entrypoint).
33+
##
34+
35+
# Run all scripts within the "entrypoint.d" directory
36+
for SCRIPT in /opt/guacamole/entrypoint.d/*.sh; do
37+
source "$SCRIPT"
38+
done
39+

0 commit comments

Comments
 (0)