GUACAMOLE-456: Merge multi-stage Docker build changes.

This commit is contained in:
Michael Jumper 2018-01-19 13:37:01 -08:00
commit 0f78b01e81
3 changed files with 84 additions and 53 deletions

View File

@ -1,3 +1,5 @@
# Docker build spec
Dockerfile
# Git repository metadata # Git repository metadata
.git .git

View File

@ -21,31 +21,20 @@
# Dockerfile for guacamole-server # Dockerfile for guacamole-server
# #
# Start from CentOS base image
FROM centos:centos7
# Environment variables # Use CentOS as base for the build
ENV \ ARG CENTOS_VERSION=centos7
BUILD_DIR=/tmp/guacd-docker-BUILD \ FROM centos:${CENTOS_VERSION} AS builder
LC_ALL=en_US.UTF-8 \
RUNTIME_DEPENDENCIES=" \ # Base directory for installed build artifacts.
cairo \ # Due to limitations of the Docker image build process, this value is
dejavu-sans-mono-fonts \ # duplicated in an ARG in the second stage of the build.
freerdp \ #
freerdp-plugins \ ARG PREFIX_DIR=/usr/local/guacamole
ghostscript \
libjpeg-turbo \ # Build arguments
libssh2 \ ARG BUILD_DIR=/tmp/guacd-docker-BUILD
liberation-mono-fonts \ ARG BUILD_DEPENDENCIES=" \
libtelnet \
libvorbis \
libvncserver \
libwebp \
pango \
pulseaudio-libs \
terminus-fonts \
uuid" \
BUILD_DEPENDENCIES=" \
autoconf \ autoconf \
automake \ automake \
cairo-devel \ cairo-devel \
@ -63,10 +52,13 @@ ENV \
pulseaudio-libs-devel \ pulseaudio-libs-devel \
uuid-devel" uuid-devel"
# Bring environment up-to-date and install guacamole-server dependencies # Build time environment
ENV LC_ALL=en_US.UTF-8
# Bring build environment up to date and install build dependencies
RUN yum -y update && \ RUN yum -y update && \
yum -y install epel-release && \ yum -y install epel-release && \
yum -y install $RUNTIME_DEPENDENCIES && \ yum -y install $BUILD_DEPENDENCIES && \
yum clean all yum clean all
# Add configuration scripts # Add configuration scripts
@ -76,13 +68,63 @@ COPY src/guacd-docker/bin /opt/guacd/bin/
COPY . "$BUILD_DIR" COPY . "$BUILD_DIR"
# Build guacamole-server from local source # Build guacamole-server from local source
RUN yum -y install $BUILD_DEPENDENCIES && \ RUN /opt/guacd/bin/build-guacd.sh "$BUILD_DIR" "$PREFIX_DIR"
/opt/guacd/bin/build-guacd.sh "$BUILD_DIR" && \
rm -Rf "$BUILD_DIR" && \ # Use same CentOS as the base for the runtime image
yum -y autoremove $BUILD_DEPENDENCIES && \ FROM centos:${CENTOS_VERSION}
yum clean all
# Base directory for installed build artifacts.
# Due to limitations of the Docker image build process, this value is
# duplicated in an ARG in the first stage of the build. See also the
# CMD directive at the end of this build stage.
#
ARG PREFIX_DIR=/usr/local/guacamole
# Runtime environment
ENV LC_ALL=en_US.UTF-8
ARG RUNTIME_DEPENDENCIES=" \
cairo \
dejavu-sans-mono-fonts \
freerdp \
freerdp-plugins \
ghostscript \
libjpeg-turbo \
libssh2 \
liberation-mono-fonts \
libtelnet \
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 --from=builder ${PREFIX_DIR} ${PREFIX_DIR}
# Link FreeRDP plugins into proper path
RUN FREERDP_DIR=$(dirname \
$(rpm -ql freerdp-libs | grep 'libfreerdp.*\.so' | head -n1)) && \
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 4822
# Start guacd, listening on port 0.0.0.0:4822 # Start guacd, listening on port 0.0.0.0:4822
EXPOSE 4822 #
CMD [ "/usr/local/sbin/guacd", "-b", "0.0.0.0", "-f" ] # Note the path here MUST correspond to the value specified in the
# PREFIX_DIR build argument.
#
CMD [ "/usr/local/guacamole/sbin/guacd", "-b", "0.0.0.0", "-f" ]

View File

@ -28,16 +28,14 @@
## The directory which currently contains the guacamole-server source and ## The directory which currently contains the guacamole-server source and
## in which the build should be performed. ## in which the build should be performed.
## ##
## @param PREFIX_DIR
## The directory prefix into which the build artifacts should be installed
## in which the build should be performed. This is passed to the --prefix
## option of `configure`.
##
BUILD_DIR="$1" BUILD_DIR="$1"
PREFIX_DIR="$2"
##
## Locates the directory in which the FreeRDP libraries (.so files) are
## located, printing the result to STDOUT.
##
where_is_freerdp() {
dirname `rpm -ql freerdp-libs | grep 'libfreerdp.*\.so' | head -n1`
}
# #
# Build guacamole-server # Build guacamole-server
@ -45,18 +43,7 @@ where_is_freerdp() {
cd "$BUILD_DIR" cd "$BUILD_DIR"
autoreconf -fi autoreconf -fi
./configure ./configure --prefix="$PREFIX_DIR"
make make
make install make install
ldconfig ldconfig
#
# Add FreeRDP plugins to proper path
#
FREERDP_DIR=`where_is_freerdp`
FREERDP_PLUGIN_DIR="$FREERDP_DIR/freerdp"
mkdir -p "$FREERDP_PLUGIN_DIR"
ln -s /usr/local/lib/freerdp/*.so "$FREERDP_PLUGIN_DIR"