GUACAMOLE-407: Merge refactor guacd Docker to debian:stable base.

This commit is contained in:
Nick Couchman 2018-04-04 17:00:30 -04:00
commit 325c8061ea
4 changed files with 178 additions and 55 deletions

View File

@ -22,9 +22,9 @@
# #
# Use CentOS as base for the build # Use Debian as base for the build
ARG CENTOS_VERSION=centos7 ARG DEBIAN_VERSION=stable
FROM centos:${CENTOS_VERSION} AS builder FROM debian:${DEBIAN_VERSION} AS builder
# Base directory for installed build artifacts. # Base directory for installed build artifacts.
# Due to limitations of the Docker image build process, this value is # Due to limitations of the Docker image build process, this value is
@ -37,41 +37,44 @@ ARG BUILD_DIR=/tmp/guacd-docker-BUILD
ARG BUILD_DEPENDENCIES=" \ ARG BUILD_DEPENDENCIES=" \
autoconf \ autoconf \
automake \ automake \
cairo-devel \
freerdp-devel \
gcc \ gcc \
libjpeg-turbo-devel \ libcairo2-dev \
libssh2-devel \ libfreerdp-dev \
libjpeg62-turbo-dev \
libossp-uuid-dev \
libpango1.0-dev \
libpulse-dev \
libssh2-1-dev \
libssl-dev \
libtelnet-dev \
libtool \ libtool \
libtelnet-devel \ libvncserver-dev \
libvorbis-devel \ libwebp-dev \
libvncserver-devel \ make"
libwebp-devel \
make \
pango-devel \
pulseaudio-libs-devel \
uuid-devel"
# Build time environment
ENV LC_ALL=en_US.UTF-8
# Bring build environment up to date and install build dependencies # Bring build environment up to date and install build dependencies
RUN yum -y update && \ RUN apt-get update && \
yum -y install epel-release && \ apt-get install -y $BUILD_DEPENDENCIES && \
yum -y install $BUILD_DEPENDENCIES && \ rm -rf /var/lib/apt/lists/*
yum clean all
# Add configuration scripts # Add configuration scripts
COPY src/guacd-docker/bin /opt/guacd/bin/ COPY src/guacd-docker/bin "${PREFIX_DIR}/bin/"
# Copy source to container for sake of build # Copy source to container for sake of build
COPY . "$BUILD_DIR" COPY . "$BUILD_DIR"
# Build guacamole-server from local source # Build guacamole-server from local source
RUN /opt/guacd/bin/build-guacd.sh "$BUILD_DIR" "$PREFIX_DIR" RUN ${PREFIX_DIR}/bin/build-guacd.sh "$BUILD_DIR" "$PREFIX_DIR"
# Use same CentOS as the base for the runtime image # Record the packages of all runtime library dependencies
FROM centos:${CENTOS_VERSION} RUN ${PREFIX_DIR}/bin/list-dependencies.sh \
${PREFIX_DIR}/sbin/guacd \
${PREFIX_DIR}/lib/libguac-client-*.so \
${PREFIX_DIR}/lib/freerdp/guac*.so \
> ${PREFIX_DIR}/DEPENDENCIES
# Use same Debian as the base for the runtime image
FROM debian:${DEBIAN_VERSION}
# Base directory for installed build artifacts. # Base directory for installed build artifacts.
# Due to limitations of the Docker image build process, this value is # Due to limitations of the Docker image build process, this value is
@ -81,43 +84,29 @@ FROM centos:${CENTOS_VERSION}
ARG PREFIX_DIR=/usr/local/guacamole ARG PREFIX_DIR=/usr/local/guacamole
# Runtime environment # Runtime environment
ENV LC_ALL=en_US.UTF-8 ENV LC_ALL=C.UTF-8
ENV LD_LIBRARY_PATH=${PREFIX_DIR}/lib
ENV GUACD_LOG_LEVEL=info ENV GUACD_LOG_LEVEL=info
ARG RUNTIME_DEPENDENCIES=" \ ARG RUNTIME_DEPENDENCIES=" \
cairo \
dejavu-sans-mono-fonts \
freerdp \
freerdp-plugins \
ghostscript \ ghostscript \
libjpeg-turbo \ libfreerdp-plugins-standard \
libssh2 \ fonts-liberation \
liberation-mono-fonts \ fonts-dejavu \
libtelnet \ xfonts-terminus"
libvorbis \
libvncserver \
libwebp \
pango \
pulseaudio-libs \
terminus-fonts \
uuid"
# Bring runtime environment up to date and install runtime dependencies
RUN yum -y update && \
yum -y install epel-release && \
yum -y install $RUNTIME_DEPENDENCIES && \
yum clean all && \
rm -rf /var/cache/yum
# Copy build artifacts into this stage # Copy build artifacts into this stage
COPY --from=builder ${PREFIX_DIR} ${PREFIX_DIR} COPY --from=builder ${PREFIX_DIR} ${PREFIX_DIR}
# Bring runtime environment up to date and install runtime dependencies
RUN apt-get update && \
apt-get install -y $RUNTIME_DEPENDENCIES && \
apt-get install -y $(cat "${PREFIX_DIR}"/DEPENDENCIES) && \
rm -rf /var/lib/apt/lists/*
# Link FreeRDP plugins into proper path # Link FreeRDP plugins into proper path
RUN FREERDP_DIR=$(dirname \ RUN ${PREFIX_DIR}/bin/link-freerdp-plugins.sh \
$(rpm -ql freerdp-libs | grep 'libfreerdp.*\.so' | head -n1)) && \ ${PREFIX_DIR}/lib/freerdp/guac*.so
FREERDP_PLUGIN_DIR="${FREERDP_DIR}/freerdp" && \
mkdir -p "$FREERDP_PLUGIN_DIR" && \
ln -s "$PREFIX_DIR"/lib/freerdp/*.so "$FREERDP_PLUGIN_DIR"
# Expose the default listener port # Expose the default listener port
EXPOSE 4822 EXPOSE 4822

View File

@ -43,7 +43,7 @@ PREFIX_DIR="$2"
cd "$BUILD_DIR" cd "$BUILD_DIR"
autoreconf -fi autoreconf -fi
./configure --prefix="$PREFIX_DIR" ./configure --prefix="$PREFIX_DIR" --disable-guaclog
make make
make install make install
ldconfig ldconfig

View File

@ -0,0 +1,86 @@
#!/bin/sh -e
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
##
## @fn link-freerdp-plugins.sh
##
## Automatically creates any required symbolic links for the proper loading of
## the given FreeRDP plugins. If a given plugin is already in the correct
## directory, no link is created for that plugin.
##
## @param ...
## The FreeRDP plugins to add links for.
##
##
## Given the full path to a FreeRDP plugin, locates the base directory of the
## associated FreeRDP installation (where the FreeRDP library .so files are
## located), printing the result to STDOUT. If the directory cannot be
## determined, an error is printed.
##
## @param PLUGIN_FILE
## The full path to the FreeRDP plugin to check.
##
where_is_freerdp() {
PLUGIN_FILE="$1"
# Determine the location of all libfreerdp* libraries explicitly linked
# to given file
PATHS="$(ldd "$PLUGIN_FILE" \
| awk '/=>/{print $(NF-1)}' \
| grep 'libfreerdp' \
| xargs -r dirname \
| xargs -r realpath \
| sort -u)"
# Verify that exactly one location was found
if [ "$(echo "$PATHS" | wc -l)" != 1 ]; then
echo "$1: Unable to locate FreeRDP install location." >&2
return 1
fi
echo "$PATHS"
}
#
# Create symbolic links as necessary to include all given plugins within the
# search path of FreeRDP
#
while [ -n "$1" ]; do
# Determine correct install location for FreeRDP plugins
FREERDP_DIR="$(where_is_freerdp "$1")"
FREERDP_PLUGIN_DIR="${FREERDP_DIR}/freerdp"
# Add symbolic link if necessary
if [ ! -e "$FREERDP_PLUGIN_DIR/$(basename "$1")" ]; then
mkdir -p "$FREERDP_PLUGIN_DIR"
ln -s "$1" "$FREERDP_PLUGIN_DIR"
else
echo "$1: Already in correct directory." >&2
fi
shift
done

View File

@ -0,0 +1,48 @@
#!/bin/sh -e
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
##
## @fn list-dependencies.sh
##
## Lists the Debian/Ubuntu package names for all library dependencies of the
## given binaries. Each package is only listed once, even if multiple binaries
## provided by the same package are given.
##
## @param ...
## The full paths to all binaries being checked.
##
while [ -n "$1" ]; do
# For all non-Guacamole library dependencies
ldd "$1" | grep -v 'libguac' | awk '/=>/{print $(NF-1)}' \
| while read LIBRARY; do
# Determine the Debian package which is associated with that
# library, if any
dpkg-query -S "$LIBRARY" 2> /dev/null || true
done
# Next binary
shift
done | cut -f1 -d: | sort -u