./gradlew \
:repose-aggregator:artifacts:docker:tagUbuntuImageVersion \ (1)
-x removeUbuntuImage (2)
This is a collection of information cobbled together from several sources, but mostly from sifting through the Official Docker Documentation and then applying it to Repose.
The rest of this assumes you are already familiar with the contents of the Quick Start and Docker recipes. Since you made it here your hunger for Repose Docker knowledge must not have been satiated, so read on and enjoy.
The Repose build system expects your Docker Hub credentials to be available at build time.
They can be passed in as build properties or the easier way is to add them to your ~/.gradle/gradle.properties
file:
dockerhub.username=<USERNAME>
dockerhub.password=<PASSWORD>
Then try to build a quick Repose Docker image from the root of the Repose project.
./gradlew \
:repose-aggregator:artifacts:docker:tagUbuntuImageVersion \ (1)
-x removeUbuntuImage (2)
1 | The Gradle task to build and tag a Repose Docker image (based on an Ubuntu image). |
2 | A Gradle option to prevent the removeUbuntuImage task from running.
This is used to prevent removal of the newly built image, getting around the task chain built when running tagUbuntuImageVersion |
This will ultimately result in a message similar to:
Successfully built IMAGE_ID Created image with ID 'IMAGE_ID'. Tagging image with ID 'IMAGE_ID'. BUILD SUCCESSFUL
Building an image to run a specific version of Repose can be done by providing the desired version as a build property.
Only images for Repose v9.0.0.0 and above can be built this way.
The Dockerfile instructions used to build the images expect to install the core of Repose from the |
./gradlew \
:repose-aggregator:artifacts:docker:tagUbuntuImageVersion \
-x removeUbuntuImage \
-Prepose-version={project-version} (1)
1 | A property declaring the version of Repose to install in the Repose Docker image. Note that setting this property will lead to Repose being installed from a remote package repository rather than local file packages. |
If you wish to tag an image yourself, an untagged image can be built.
./gradlew \
:repose-aggregator:artifacts:docker:buildUbuntuImageLocal (1)
1 | The Gradle task to build a Repose Docker image (based on an Ubuntu image). |
Using the IMAGE_ID
provided in the Gradle output (or via a docker images
query), tag the new Repose Docker image.
docker tag IMAGE_ID local/repose:v{project-version}-ubuntu
The published images adhere to the expectations of Twelve-Factor App logging via streaming everything to STDOUT
/STDERR
and this is covered further in the Quick Start.
Sometimes though, it may be handy to enable the regular Repose Valve logging that is disabled in the published images.
If you are using a published image, then you can execute an interactive session on a running container and uncomment the two AppenderRef
lines below in the logging configuration file to begin logging to the standard /var/log/repose/
location inside the container:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="15" packages="org.apache.logging.log4j.flume.appender">
...
<AppenderRef ref="RollingFile"/>
...
<AppenderRef ref="PhoneHomeMessages"/>
...
</Configuration>
If you are building your own image based on one of the Repose Dockerfile's, then you can simply remove the lines below and the Repose image will log to the standard /var/log/repose/
location.
RUN sed -i 's,<\(Appender.*RollingFile.*/\)>,<!--\1-->,' ${APP_ROOT}/log4j2.xml RUN sed -i 's,<\(Appender.*PhoneHomeMessages.*/\)>,<!--\1-->,' ${APP_ROOT}/log4j2.xml
The /var/log/repose/
logging directory has also been modified in the Dockerfile to allow logging to be turned on and also support arbitrary user ID’s like are used in the OpenShift environment.
To access the Repose log files, you can mount the directory as a Docker volume when starting the container using a command like the following:
docker run \ --detach \ --volume /my/config/directory:/etc/repose \ --volume /var/log/repose:/var/log/repose \ (1) --publish 8080:8080 \ --env JAVA_OPTS=-Xmx1024m \ --name my_repose \ rackerlabs/repose:latest
1 | This option defines a volume that is mounted from the host (i.e., the OS running Docker) onto the Docker container.
The volume mapping format is HOST_DIRECTORY:CONTAINER_DIRECTORY .
So in this case, the contents of /var/log/repose in the container will be available on the host’s /var/log/repose directory.
This allows us to tail or persist the logs even if the Docker container is restarted. |
If you didn’t recognize it, this is almost identical to the command provided in Using a Repose Docker Image, but with the extra volume mount option.