Skip to content

Instantly share code, notes, and snippets.

@literalplus
Last active April 2, 2018 17:29
Show Gist options
  • Save literalplus/2170acf1c2be5c3d8c5a74e0ef929048 to your computer and use it in GitHub Desktop.
Save literalplus/2170acf1c2be5c3d8c5a74e0ef929048 to your computer and use it in GitHub Desktop.
Start Artifactory in a Docker container and configure it to run without context path (i.e. from / instead of /artifactory )
#!/bin/bash
docker pull docker.bintray.io/jfrog/artifactory-oss:latest
echo "Running docker container yay"
CONTAINER_ID=$(docker run --name artifactory -d -p 8081:8081 \
-v /var/www/artifactory:/var/opt/jfrog/artifactory \
--restart unless-stopped \
docker.bintray.io/jfrog/artifactory-oss:latest)
RUN_RES="$?"
if [ "$RUN_RES" -ne 0 ]; then
echo "Unable to start container, sorry."
exit $RUN_RES
fi
echo "Started as $CONTAINER_ID."
echo "Configuring to run as ROOT app"
# https://jfrog.com/knowledge-base/how-do-i-setup-artifactory-to-run-as-the-root-application-in-tomcat/
ARTIFACTORY_HOME="/opt/jfrog/artifactory"
WEBAPPS="$ARTIFACTORY_HOME/webapps"
XMLS="$ARTIFACTORY_HOME/tomcat/conf/Catalina/localhost"
docker exec $CONTAINER_ID /usr/bin/mv $WEBAPPS/artifactory.war $WEBAPPS/ROOT.war
docker exec $CONTAINER_ID /usr/bin/mv $XMLS/artifactory.xml $XMLS/ROOT.xml
docker exec $CONTAINER_ID /usr/bin/sed -i.bkp 's/path="\/artifactory"/path="\/"/' $XMLS/ROOT.xml
docker exec $CONTAINER_ID /usr/bin/sed -i.bkp 's/artifactory.war/ROOT.war/' $XMLS/ROOT.xml
docker exec $CONTAINER_ID /usr/bin/rm -rf $ARTIFACTORY_HOME/tomcat/work/Catalina
docker exec $CONTAINER_ID /usr/bin/rm -rf $ARTIFACTORY_HOME/tomcat/webapps/ROOT/
docker exec $CONTAINER_ID /usr/bin/rm -rf $ARTIFACTORY_HOME/tomcat/webapps/artifactory/
docker restart $CONTAINER_ID
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment