Skip to content

Instantly share code, notes, and snippets.

@jmewes
Last active January 28, 2018 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmewes/e8a6738f3c6dd5fabc27f5e8f7dd4c91 to your computer and use it in GitHub Desktop.
Save jmewes/e8a6738f3c6dd5fabc27f5e8f7dd4c91 to your computer and use it in GitHub Desktop.
Develop CaptainCasa apps with Docker

CaptainCasa

This document describes how to build and run a Docker image for the CaptainCasa editor.

Dependencies

This approach assumes that the following tools are installed:

Download the util files

git clone https://gist.github.com/e8a6738f3c6dd5fabc27f5e8f7dd4c91.git cc-editor
cd cc-editor

Building the Docker image

./build-editor-image.sh -e ${DOWNLOAD_DIR}/EnterpriseClientRISC_${VERSION}/webapplications/editor.war

Start the editor

./start-editor.sh -d ${WORKSPACE}/${PROJECT}
./start-editor.sh -d ${WORKSPACE}/${PROJECT} -p 8081

Access the editor in the browser

Linux

firefox http://localhost:8080

MacOS

open http://${DOCKER_IP}:8080
#!/bin/bash
# Check that dependencies for this script are installed
which readlink > /dev/null || { echo "Tool 'readlink' not installed." >&2 ; exit 1; }
which docker > /dev/null || { echo "Tool 'docker' not installed. See https://www.docker.com/get-docker" >&2 ; exit 1; }
# Evaluate script parameter
while getopts "e:" opt; do
case $opt in
e)
WAR_FILE=${OPTARG}
;;
esac
done
if [[ -z ${WAR_FILE} ]]; then
echo "Script parameter -e for the path to the 'editor.war' file not specified." >&2
exit 1
fi
if [[ ! -f ${WAR_FILE} ]]; then
echo "The file '${WAR_FILE}' does not exist." >&2
exit 1
fi
# Change current directory to the directory where this script resides
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${SCRIPT_DIR}
# Copy the war file here to be able to access it from the Dockerfile
cp ${WAR_FILE} editor.war
# Build the Docker image
docker build -t cc-editor .
# Remove the editor copy after the Docker image creation
rm editor.war
FROM tomcat
ENV JAVA_OPTS="-Djava.security.egd=file:/dev/urandom"
RUN addgroup tomcatusers && adduser --disabled-password tomcat && adduser tomcat tomcatusers
RUN chown -R tomcat:tomcatusers .
USER tomcat
COPY editor.war /usr/local/tomcat/webapps/editor.war
COPY index.jsp /usr/local/tomcat/webapps/ROOT/index.jsp
<% response.sendRedirect("editor/editor.tools.risc?ccstyle=cceditorlightrisc&ccconfirmexit=false"); %>
Copyright 2017 Jan Mewes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#!/bin/bash
# Evaluate script parameters
HOST_PORT_NUMBER=8080
while getopts "d: p:" opt; do
case $opt in
d)
PROJECT_DIRECTORY=${OPTARG}
;;
p)
HOST_PORT_NUMBER=${OPTARG}
;;
esac
done
if [[ -z ${PROJECT_DIRECTORY} ]]; then
echo "Script parameter -d for project directory not specified." >&2
exit 1
fi
if [[ ! -d ${PROJECT_DIRECTORY} ]]; then
echo "Project directory '${PROJECT_DIRECTORY}' does not exist." >&2
exit 1
fi
# Transform relative path declaration to absolute path to file
PROJECT_DIRECTORY=$(readlink -f ${PROJECT_DIRECTORY})
# Start the editor
docker run --rm -v ${PROJECT_DIRECTORY}:/home/workspace -p ${HOST_PORT_NUMBER}:8080 cc-editor
@jmewes
Copy link
Author

jmewes commented Jan 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment