From 71b7a27179f5d3624501e299b2ec0ae7ce749ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Hedenstr=C3=B6m?= <erik@codemate.se> Date: Thu, 31 Jul 2014 16:40:44 +0200 Subject: [PATCH] Bumped JIRA version. Added self-signed cert. Tweaked README.md --- Dockerfile | 33 +++++++++++++++++++++++++++++---- README.md | 32 ++++++++++++++++++++++++-------- init.sh | 34 ++++++++++++++++++++++++++++------ 3 files changed, 81 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d00cf3..162f6a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,19 +12,44 @@ ENV DEBIAN_PRIORITY critical ENV DEBCONF_NOWARNINGS yes # Set Timezone -RUN echo "Europe/Stockholm" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata +RUN \ + echo "Europe/Stockholm" > /etc/timezone && \ + dpkg-reconfigure -f noninteractive tzdata # Fix locale -RUN locale-gen en_US.UTF-8 -RUN echo "LANG=\"en_US.UTF-8\"" > /etc/default/locale && echo "LANGUAGE=\"en_US:en\"" >> /etc/default/locale +RUN \ + locale-gen en_US.UTF-8 && \ + echo "LANG=\"en_US.UTF-8\"" > /etc/default/locale && \ + echo "LANGUAGE=\"en_US.UTF8\"" >> /etc/default/locale && \ + echo "LC_ALL=\"en_US.UTF8\"" >> /etc/default/locale + +# Import self-signed cert as trusted CA +RUN \ + openssl s_client -servername cert.codemate.se -connect codemate.se:443 </dev/null | sed -ne '/--BEGIN CERTIFICATE--/,/--END CERTIFICATE--/p' > /tmp/codemate.cert && \ + keytool -import -noprompt -trustcacerts -keystore /usr/lib/jvm/java-7-oracle/jre/lib/security/cacerts -storepass changeit -noprompt -alias codemate-self-signed -file /tmp/codemate.cert + +# Install and configure Exim +RUN \ + apt-get -y install exim4-daemon-light && \ + sed -i -e "s/dc_eximconfig_configtype='local'/dc_eximconfig_configtype='internet'/" /etc/exim4/update-exim4.conf.conf && \ + sed -i -e "s/127.0.0.1/0.0.0.0/" /etc/exim4/update-exim4.conf.conf && \ + update-exim4.conf + +# Install and configure MySQL +RUN \ + apt-get -y install mysql-server && \ + sed -i -e "s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf # Default Environment -ENV JIRA_VERSION 6.2 +ENV JIRA_VERSION 6.3.1 ENV JIRA_HOME /home/jira # Add startup script ADD init.sh /init.sh # Start JIRA +EXPOSE 25 +EXPOSE 3306 EXPOSE 8080 +EXPOSE 8081 CMD ["sh", "/init.sh"] diff --git a/README.md b/README.md index 9d88b8d..c434427 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Docker image to run [Atlassian JIRA](https://www.atlassian.com/software/jira). ## Building ``` -docker build -rm -t registry.codemate.se/jira . +docker build --rm -t registry.codemate.se/jira . ``` ## Usage @@ -39,15 +39,15 @@ docker run -v /data/jira:/home/jira -d registry.codemate.se/jira ### Running a different JIRA version -By default, the container downloads and installs JIRA v6.2 on the first boot. To specify which version to install, set the environment variable `JIRA_VERSION`: +By default, the container downloads and installs JIRA v6.3.1 on the first boot. To specify which version to install, set the environment variable `JIRA_VERSION`: ``` -docker run -e JIRA_VERSION=6.2 -d registry.codemate.se/jira +docker run -e JIRA_VERSION=6.3.1 -d registry.codemate.se/jira ``` -### Overiding JIRA files +### Overriding JIRA files -By providing an environment variable name `JIRA_OVERLAY` that points to a gzipped tar file you can apply an overlay on the JIRA installation. This tarball will be unzipped and extracted in the root of the JIRA installation directory. The overlay enables you to add custom jira configuratios such as SSL or Crowd integration. +By providing an environment variable name `JIRA_OVERLAY` that points to a gzipped tar file you can apply an overlay on the JIRA installation. This tarball will be unzipped and extracted in the root of the JIRA installation directory. The overlay enables you to add custom jira configurations such as SSL or Crowd integration. ``` docker run -e JIRA_OVERLAY=http://10.0.0.1/jira-config.tgz -d registry.codemate.se/jira @@ -59,17 +59,29 @@ The overlay is fetched using curl so if you need to provide basic auth credentia JIRA_OVERLAY="-u username:password http://10.0.0.1/jira-config.tgz" ``` +### Initializing MySQL + +By providing an environment variable name `MYSQL_INIT` that points to an SQL script you initialize the MySQL database. + +``` +docker run -e MYSQL_INIT=http://10.0.0.1/jira-init.sql -d registry.codemate.se/jira +``` + +Basic auth credentials can be used as mentioned in the JIRA overlay section. + ### Combined options The following example shows the options we use for our CI environment: ``` -docker run -name jira \ +docker run \ + --name jira \ -e JAVA_OPTS=-Xmx1024m \ - -e JIRA_VERSION=6.2 \ + -e JIRA_VERSION=6.3.1 \ -e JIRA_OVERLAY=http://10.0.0.1/jira-config.tgz \ -v /opt/application-data/jira:/home/jira \ -p 8080:8080 \ + -p 8081:8081 \ -d registry.codemate.se/jira ``` @@ -81,9 +93,13 @@ docker run -name jira \ ## Variables * `JIRA_HOME` - JIRA home directory (default `/home/jira`) -* `JIRA_VERSION` - The version to install an run (default `6.2`) +* `JIRA_VERSION` - The version to install an run (default `6.3.1`) * `JIRA_OVERLAY` - A URL pointing to an tarball overlay +* `MYSQL_INIT` - A URL pointing to an SQL script ## Exposed ports +* `25` - Exim SMTP +* `3306` - MySQL * `8080` - JIRA web interface +* `8081` - JIRA web interface (extra) diff --git a/init.sh b/init.sh index b2e9c45..836c41c 100644 --- a/init.sh +++ b/init.sh @@ -4,24 +4,46 @@ set -e # Exit on errors SEPARATOR="-------------------------------------------------------------------------------" JIRA_DIR=/opt/atlassian-jira-$JIRA_VERSION-standalone - -if [ ! -d $JIRA_HOME ]; then - mkdir -p $JIRA_HOME -fi +MYSQL_DIR=$JIRA_HOME/mysql-data if [ ! -d $JIRA_DIR ]; then curl -s -v -L http://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-$JIRA_VERSION.tar.gz | tar xzf - -C /opt - echo "$SEPARATOR" + curl -s -v -L -o $JIRA_DIR/lib/mysql-connector-java-5.1.31.jar http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.31/mysql-connector-java-5.1.30.jar + echo "$SEPARATOR" fi if [ ${JIRA_OVERLAY:+x} ] && [ -d $JIRA_DIR ]; then curl -s -v -L $JIRA_OVERLAY | tar xzf - -C $JIRA_DIR - echo "$SEPARATOR" + echo "$SEPARATOR" fi chown -R root:root $JIRA_DIR +if [ ! -d $JIRA_HOME ]; then + mkdir -p $JIRA_HOME +fi + +if [ ! -d $MYSQL_DIR ]; then + mkdir -p $MYSQL_DIR + sed -i -e "s#^user\s*=\s*mysql#user = root#" /etc/mysql/my.cnf + sed -i -e "s#^datadir\s*=\s*/var/lib/mysql#datadir = $MYSQL_DIR#" /etc/mysql/my.cnf + mysql_install_db + mysqld_safe & + sleep 5s + echo "$SEPARATOR" +else + mysqld_safe & + sleep 5s +fi + +if [ ${MYSQL_INIT:+x} ] && [ -d $MYSQL_DIR ]; then + curl -s -v -L $MYSQL_INIT | mysql + echo "$SEPARATOR" +fi + env | sort echo "$SEPARATOR" +exim4 -v -bdf -q15m & + $JIRA_DIR/bin/start-jira.sh -fg -- GitLab