GUACAMOLE-408: Merge support for Docker multi-stage builds.

This commit is contained in:
Michael Jumper
2017-10-07 23:13:58 -07:00
3 changed files with 22 additions and 17 deletions

View File

@@ -1,6 +1,5 @@
.git .git
**/.gitignore
**/*~ **/*~
**/target/ **/target/

View File

@@ -21,29 +21,36 @@
# Dockerfile for guacamole-client # Dockerfile for guacamole-client
# #
# Start from Tomcat image # Use args for Tomcat image label to allow image builder to choose alternatives
FROM tomcat:8.0.20-jre8 # such as `--build-arg TOMCAT_JRE=jre8-alpine`
#
ARG TOMCAT_VERSION=8.0.20
ARG TOMCAT_JRE=jre8
# Environment variables # Use official maven image for the build
FROM maven:3-jdk-8 AS builder
# Build environment variables
ENV \ ENV \
BUILD_DIR=/tmp/guacamole-docker-BUILD \ BUILD_DIR=/tmp/guacamole-docker-BUILD
BUILD_DEPENDENCIES=" \
maven \
openjdk-8-jdk-headless"
# Add configuration scripts # Add configuration scripts
COPY guacamole-docker/bin /opt/guacamole/bin/ COPY guacamole-docker/bin/ /opt/guacamole/bin/
# Copy source to container for sake of build # Copy source to container for sake of build
COPY . "$BUILD_DIR" COPY . "$BUILD_DIR"
# Build latest guacamole-client and authentication # Run the build itself
RUN apt-get update && \ RUN /opt/guacamole/bin/build-guacamole.sh "$BUILD_DIR" /opt/guacamole
apt-get install -y --no-install-recommends $BUILD_DEPENDENCIES && \
/opt/guacamole/bin/build-guacamole.sh "$BUILD_DIR" /opt/guacamole && \ # For the runtime image, we start with the official Tomcat distribution
rm -Rf "$BUILD_DIR" && \ FROM tomcat:${TOMCAT_VERSION}-${TOMCAT_JRE}
rm -Rf /var/lib/apt/lists/* && \
apt-get purge -y --auto-remove $BUILD_DEPENDENCIES # This is where the build artifacts go in the runtime image
WORKDIR /opt/guacamole
# Copy artifacts from builder image into this image
COPY --from=builder /opt/guacamole/ .
# Start Guacamole under Tomcat, listening on 0.0.0.0:8080 # Start Guacamole under Tomcat, listening on 0.0.0.0:8080
EXPOSE 8080 EXPOSE 8080

View File

@@ -54,7 +54,6 @@ mkdir -p "$DESTINATION"
cd "$BUILD_DIR" cd "$BUILD_DIR"
mvn package mvn package
rm -Rf ~/.m2
# #
# Copy guacamole.war to destination # Copy guacamole.war to destination