This Dockerfile allows you to build images to deploy your own YouTrack instance. It has been tested on Fedora 23 and CentOS 7.
Please remember to back up your data directories often, especially before upgrading to a newer version.
docker run -it -p 8080:8080 agross/youtrack
http://localhost:8080.YOUTRACK_DATA="/var/data/youtrack"
YOUTRACK_LOGS="/var/log/youtrack"
DOMAIN=example.com
PORT=8012
mkdir --parents "$YOUTRACK_DATA/backups" \
"$YOUTRACK_DATA/conf" \
"$YOUTRACK_DATA/data" \
"$YOUTRACK_LOGS"
The Dockerfile creates a youtrack user and group. This user has a UID and GID of 5000. Make sure to add a user to your host system with this UID and GID and allow this user to read and write to $YOUTRACK_DATA and $YOUTRACK_LOGS. The name of the host user and group in not important.
# Create youtrack group and user in docker host, e.g.:
groupadd --gid 5000 --system youtrack
useradd --uid 5000 --gid 5000 --system --shell /sbin/nologin --comment "JetBrains YouTrack" youtrack
# 5000 is the ID of the youtrack user and group created by the Dockerfile.
chown -R 5000:5000 "$YOUTRACK_DATA" "$YOUTRACK_LOGS"
Note: The :z option on the volume mounts makes sure the SELinux context of the directories are set appropriately.
/etc/localtime needs to be bind-mounted to use the same time zone as your docker host.
docker create -it -p $PORT:8080 \
-v /etc/localtime:/etc/localtime:ro \
-v "$YOUTRACK_DATA/backups:/youtrack/backups:z" \
-v "$YOUTRACK_DATA/conf:/youtrack/conf:z" \
-v "$YOUTRACK_DATA/data:/youtrack/data:z" \
-v "$YOUTRACK_LOGS:/youtrack/logs:z" \
--name youtrack \
agross/youtrack
/etc/systemd/system/youtrack.service.cat <<EOF > "/etc/systemd/system/youtrack.service"
[Unit]
Description=JetBrains YouTrack
Requires=docker.service
After=docker.service
[Service]
Restart=always
# When docker stop is executed, the docker-entrypoint.sh trap + wait combination
# will generate an exit status of 143 = 128 + 15 (SIGTERM).
# More information: http://veithen.github.io/2014/11/16/sigterm-propagation.html
SuccessExitStatus=143
PrivateTmp=true
ExecStart=/usr/bin/docker start --attach=true youtrack
ExecStop=/usr/bin/docker stop --time=60 youtrack
[Install]
WantedBy=multi-user.target
EOF
systemctl enable youtrack.service
systemctl start youtrack.service
/etc/logrotate.d/youtrack.cat <<EOF > "/etc/logrotate.d/youtrack"
$YOUTRACK_LOGS/*.log
$YOUTRACK_LOGS/hub/*.log
$YOUTRACK_LOGS/hub/logs/*.log
$YOUTRACK_LOGS/youtrack/*.log
$YOUTRACK_LOGS/youtrack/logs/*.log
$YOUTRACK_LOGS/internal/services/bundleProcess/*.log
{
rotate 7
daily
dateext
missingok
notifempty
sharedscripts
copytruncate
compress
}
EOF
/etc/nginx/conf.d/youtrack.conf.cat <<EOF > "/etc/nginx/conf.d/youtrack.conf"
upstream youtrack {
server localhost:$PORT;
}
server {
listen 80;
listen [::]:80;
server_name $DOMAIN;
access_log /var/log/nginx/$DOMAIN.access.log;
error_log /var/log/nginx/$DOMAIN.error.log;
# Do not limit upload.
client_max_body_size 0;
# Required to avoid HTTP 411: see issue #1486 (https://github.com/dotcloud/docker/issues/1486)
chunked_transfer_encoding on;
location / {
proxy_pass http://youtrack;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-Host \$http_host;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_http_version 1.1;
}
location /api/eventSourceBus {
proxy_pass http://youtrack;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-Host \$http_host;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_http_version 1.1;
proxy_cache off;
proxy_buffering off;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
proxy_set_header Connection '';
chunked_transfer_encoding off;
}
}
EOF
nginx -s reload
Make sure SELinux policy allows nginx to access port $PORT (the first part of -p $PORT:8080 of step 3).
if [ $(semanage port --list | grep --count "^http_port_t.*$PORT") -eq 0 ]; then
if semanage port --add --type http_port_t --proto tcp $PORT; then
echo Added port $PORT as a valid port for nginx:
semanage port --list | grep ^http_port_t
else
>&2 echo Could not add port $PORT as a valid port for nginx. Please add it yourself. More information: http://axilleas.me/en/blog/2013/selinux-policy-for-nginx-and-gitlab-unix-socket-in-fedora-19/
fi
else
echo Port $PORT is already a valid port for nginx:
semanage port --list | grep ^http_port_t
fi
Follow the steps of the installation instructions for JetBrains YouTrack using paths inside the docker container located under
/youtrack/backups,/youtrack/data,/youtrack/logs and/youtrack/temp.docker pull agross/youtrack
systemctl stop youtrack.service
# Back up $YOUTRACK_DATA.
tar -zcvf "youtrack-data-$(date +%F-%H-%M-%S).tar.gz" "$YOUTRACK_DATA"
docker rm youtrack
# Repeat step 4 and create a new image.
docker create ...
systemctl start youtrack.service
DockerfileDockerfile.docker build --tag agross/youtrack:testing .
docker images
# Should contain:
# REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
# agross/youtrack testing 0dcb8bf6093f 49 seconds ago 405.4 MB
TEST_DIR="/tmp/youtrack-testing"
mkdir --parents "$TEST_DIR/backups" \
"$TEST_DIR/conf" \
"$TEST_DIR/data" \
"$TEST_DIR/logs"
chown -R 5000:5000 "$TEST_DIR"
Note: The :z option on the volume mounts makes sure the SELinux context of the directories are set appropriately.
docker run -it --rm \
--name youtrack-testing \
-p 8080:8080 \
-v "$TEST_DIR/backups:/youtrack/backups:z" \
-v "$TEST_DIR/conf:/youtrack/conf:z" \
-v "$TEST_DIR/data:/youtrack/data:z" \
-v "$TEST_DIR/logs:/youtrack/logs:z" \
agross/youtrack:testing
docker exec -it youtrack-testing bash
Note: The :z option on the volume mounts makes sure the SELinux context of the directories are set appropriately.
docker run -it -v "$TEST_DIR/backups:/youtrack/backups:z" \
-v "$TEST_DIR/conf:/youtrack/conf:z" \
-v "$TEST_DIR/data:/youtrack/data:z" \
-v "$TEST_DIR/logs:/youtrack/logs:z" \
agross/youtrack:testing bash
Without mounted data directories:
docker run -it agross/youtrack:testing bash
docker ps -aq --no-trunc --filter ancestor=agross/youtrack:testing | xargs --no-run-if-empty docker rm
docker images -q --no-trunc agross/youtrack:testing | xargs --no-run-if-empty docker rmi
rm -rf "$TEST_DIR"
Content type
Image
Digest
sha256:596da6870…
Size
616.8 MB
Last updated
over 2 years ago
docker pull agross/youtrack