├── .dockerignore ├── .gitignore ├── Dockerfile ├── Makefile ├── README.md ├── onbuild ├── Dockerfile ├── trigger └── urlrewrite │ └── WEB-INF │ ├── lib │ └── urlrewritefilter.jar │ ├── urlrewrite.xml │ └── web-fragment.xml └── urlrewrite └── WEB-INF ├── lib └── urlrewritefilter.jar ├── urlrewrite.xml └── web-fragment.xml /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | README.md 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tomcat:7-jre7 2 | 3 | MAINTAINER Matthias Grüter 4 | 5 | # To update, check https://bintray.com/jfrog/artifactory/jfrog-artifactory-oss-zip/view 6 | ENV ARTIFACTORY_VERSION 3.9.4 7 | ENV ARTIFACTORY_SHA1 e42ecd584a56fc14094548a408b61e5bc9bcac42 8 | 9 | # Disable Tomcat's manager application. 10 | RUN rm -rf webapps/* 11 | 12 | # Redirect URL from / to artifactory/ using UrlRewriteFilter 13 | COPY urlrewrite/WEB-INF/lib/urlrewritefilter.jar / 14 | COPY urlrewrite/WEB-INF/urlrewrite.xml / 15 | RUN \ 16 | mkdir -p webapps/ROOT/WEB-INF/lib && \ 17 | mv /urlrewritefilter.jar webapps/ROOT/WEB-INF/lib && \ 18 | mv /urlrewrite.xml webapps/ROOT/WEB-INF/ 19 | 20 | # Fetch and install Artifactory OSS war archive. 21 | RUN \ 22 | echo $ARTIFACTORY_SHA1 artifactory.zip > artifactory.zip.sha1 && \ 23 | curl -L -o artifactory.zip https://bintray.com/artifact/download/jfrog/artifactory/artifactory-${ARTIFACTORY_VERSION}.zip && \ 24 | sha1sum -c artifactory.zip.sha1 && \ 25 | unzip -j artifactory.zip "artifactory-*/webapps/artifactory.war" -d webapps && \ 26 | rm artifactory.zip 27 | 28 | # Expose tomcat runtime options through the RUNTIME_OPTS environment variable. 29 | # Example to set the JVM's max heap size to 256MB use the flag 30 | # '-e RUNTIME_OPTS="-Xmx256m"' when starting a container. 31 | RUN echo 'export CATALINA_OPTS="$RUNTIME_OPTS"' > bin/setenv.sh 32 | 33 | # Artifactory home 34 | RUN mkdir -p /artifactory 35 | ENV ARTIFACTORY_HOME /artifactory 36 | 37 | # Expose Artifactories data, log and backup directory. 38 | VOLUME /artifactory/data 39 | VOLUME /artifactory/logs 40 | VOLUME /artifactory/backup 41 | 42 | WORKDIR /artifactory 43 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: image onbuild/image 2 | 3 | Dockerfile: 4 | cp Dockerfile.in Dockerfile 5 | 6 | .PHONY: image 7 | image: Dockerfile 8 | docker build -t mattgruter/artifactory:latest . 9 | 10 | onbuild/Dockerfile: Dockerfile 11 | cat Dockerfile onbuild/trigger > onbuild/Dockerfile 12 | 13 | onbuild/urlrewrite: 14 | cp --no-target-directory --recursive urlrewrite/ onbuild/urlrewrite 15 | 16 | .PHONY: onbuild/image 17 | onbuild/image: onbuild/Dockerfile onbuild/urlrewrite 18 | docker build -t mattgruter/artifactory:latest-onbuild onbuild 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Artifactory 2 | 3 | Run [Artifactory](http://www.jfrog.com/home/v_artifactory_opensource_overview) inside a Docker container. 4 | 5 | Link: [mattgruter/artifactory](https://registry.hub.docker.com/u/mattgruter/artifactory/) 6 | 7 | 8 | ## Volumes 9 | Artifactories `data`, `logs` and `backup` directories are exported as volumes: 10 | 11 | /artifactory/data 12 | /artifactory/logs 13 | /artifactory/backup 14 | 15 | ## Ports 16 | The web server is accessible through port `8080`. 17 | 18 | ## Example 19 | To run artifactory do: 20 | 21 | docker run -p 8080:8080 mattgruter/artifactory 22 | 23 | Now point your browser to http://localhost:8080 24 | 25 | 26 | ## URLs 27 | The artifactory servlet is available at the `artifactory/` path. However a filter redirects all paths outside of `artifactory/` to the artifactory servlet. Thus instead of linking to the URL http://localhost:8080/artifactory/libs-release-local you can just link to http://localhost:8080/libs-release-local (i.e. omitting the subpath `artifactory/`). 28 | 29 | ## Runtime options 30 | Inject the environment variable `RUNTIME_OPTS` when starting a container to set Tomcat's runtime options (i.e. `CATALANA_OPTS`). The most common use case is to set the heap size: 31 | 32 | docker run -e RUNTIME_OPTS="-Xms256m -Xmx512m" -P mattgruter/artifactory 33 | 34 | ## Switching to Artifactory Pro 35 | If you are using Artifactory Pro, the artifactory war archive has to be replaced. The image tagged `-onbuild` is built with an `ONBUILD` trigger for this purpose. Unpack the Artifactory Pro distribution ZIP file and place the file `artifactory.war` (located in the archive) in the same directory as a simple Dockerfile that extends the `onbuild` image: 36 | 37 | # Dockerfile for Artifactory Pro 38 | FROM mattgruter/artifactory:latest-onbuild 39 | 40 | Now build your child docker image: 41 | 42 | docker build -t yourname/myartifactory . 43 | 44 | The `ONBUILD` trigger ensures your `artifactory.war` is picked up and applied to the image upon build. 45 | 46 | docker run -P yourname/myartifactory 47 | -------------------------------------------------------------------------------- /onbuild/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tomcat:7-jre7 2 | 3 | MAINTAINER Matthias Grüter 4 | 5 | # To update, check https://bintray.com/jfrog/artifactory/jfrog-artifactory-oss-zip/view 6 | ENV ARTIFACTORY_VERSION 3.9.4 7 | ENV ARTIFACTORY_SHA1 e42ecd584a56fc14094548a408b61e5bc9bcac42 8 | 9 | # Disable Tomcat's manager application. 10 | RUN rm -rf webapps/* 11 | 12 | # Redirect URL from / to artifactory/ using UrlRewriteFilter 13 | COPY urlrewrite/WEB-INF/lib/urlrewritefilter.jar / 14 | COPY urlrewrite/WEB-INF/urlrewrite.xml / 15 | RUN \ 16 | mkdir -p webapps/ROOT/WEB-INF/lib && \ 17 | mv /urlrewritefilter.jar webapps/ROOT/WEB-INF/lib && \ 18 | mv /urlrewrite.xml webapps/ROOT/WEB-INF/ 19 | 20 | # Fetch and install Artifactory OSS war archive. 21 | RUN \ 22 | echo $ARTIFACTORY_SHA1 artifactory.zip > artifactory.zip.sha1 && \ 23 | curl -L -o artifactory.zip https://bintray.com/artifact/download/jfrog/artifactory/artifactory-${ARTIFACTORY_VERSION}.zip && \ 24 | sha1sum -c artifactory.zip.sha1 && \ 25 | unzip -j artifactory.zip "artifactory-*/webapps/artifactory.war" -d webapps && \ 26 | rm artifactory.zip 27 | 28 | # Expose tomcat runtime options through the RUNTIME_OPTS environment variable. 29 | # Example to set the JVM's max heap size to 256MB use the flag 30 | # '-e RUNTIME_OPTS="-Xmx256m"' when starting a container. 31 | RUN echo 'export CATALINA_OPTS="$RUNTIME_OPTS"' > bin/setenv.sh 32 | 33 | # Artifactory home 34 | RUN mkdir -p /artifactory 35 | ENV ARTIFACTORY_HOME /artifactory 36 | 37 | # Expose Artifactories data, log and backup directory. 38 | VOLUME /artifactory/data 39 | VOLUME /artifactory/logs 40 | VOLUME /artifactory/backup 41 | 42 | WORKDIR /artifactory 43 | # Add hook to install custom artifactory.war (i.e. Artifactory Pro) to replace OSS distribution. 44 | ONBUILD COPY artifactory.war $CATALINA_HOME/webapps/artifactory.war 45 | -------------------------------------------------------------------------------- /onbuild/trigger: -------------------------------------------------------------------------------- 1 | # Add hook to install custom artifactory.war (i.e. Artifactory Pro) to replace OSS distribution. 2 | ONBUILD COPY artifactory.war $CATALINA_HOME/webapps/artifactory.war 3 | -------------------------------------------------------------------------------- /onbuild/urlrewrite/WEB-INF/lib/urlrewritefilter.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattgruter/dockerfile-artifactory/1f46912675bfb0f4df75a03ed96064eefc676924/onbuild/urlrewrite/WEB-INF/lib/urlrewritefilter.jar -------------------------------------------------------------------------------- /onbuild/urlrewrite/WEB-INF/urlrewrite.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | redirect from / to artifactory url 4 | artifactory 5 | ^/(.*)$ 6 | /artifactory/$1 7 | 8 | 9 | -------------------------------------------------------------------------------- /onbuild/urlrewrite/WEB-INF/web-fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | UrlRewriteFilter 4 | org.tuckey.web.filters.urlrewrite.UrlRewriteFilter 5 | 6 | statusEnabledOnHosts 7 | * 8 | 9 | 10 | 11 | UrlRewriteFilter 12 | /* 13 | REQUEST 14 | FORWARD 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /urlrewrite/WEB-INF/lib/urlrewritefilter.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattgruter/dockerfile-artifactory/1f46912675bfb0f4df75a03ed96064eefc676924/urlrewrite/WEB-INF/lib/urlrewritefilter.jar -------------------------------------------------------------------------------- /urlrewrite/WEB-INF/urlrewrite.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | redirect from / to artifactory url 4 | artifactory 5 | ^/(.*)$ 6 | /artifactory/$1 7 | 8 | 9 | -------------------------------------------------------------------------------- /urlrewrite/WEB-INF/web-fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | UrlRewriteFilter 4 | org.tuckey.web.filters.urlrewrite.UrlRewriteFilter 5 | 6 | statusEnabledOnHosts 7 | * 8 | 9 | 10 | 11 | UrlRewriteFilter 12 | /* 13 | REQUEST 14 | FORWARD 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------