From 45a1cc0557737506d64744a3f2c5e3491a7789f3 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 15 Feb 2018 16:52:47 +0100 Subject: [PATCH] Add `JLS_CONTEXT` env var Ability to set a custom UID / GID Timezone was not setted No need of Nginx Error while saving stats --- CHANGELOG.md | 8 +++++ Dockerfile | 10 +++--- README.md | 10 +++--- assets/etc/nginx/nginx.conf | 36 ---------------------- assets/etc/supervisord.conf | 28 ++++++++--------- assets/etc/supervisord/license-server.conf | 5 +++ docker-compose.yml | 1 + entrypoint.sh | 29 +++++++++++++++-- 8 files changed, 63 insertions(+), 64 deletions(-) delete mode 100644 assets/etc/nginx/nginx.conf create mode 100644 assets/etc/supervisord/license-server.conf diff --git a/CHANGELOG.md b/CHANGELOG.md index d459fc8..83d215b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 15802-RC2 (2018/02/15) + +* Add `JLS_CONTEXT` env var +* Ability to set a custom UID / GID +* Timezone was not setted +* No need of Nginx +* Error while saving stats + ## 15802-RC1 (2018/02/01) * Initial version based on JetBrains License Server 15802 diff --git a/Dockerfile b/Dockerfile index 5944cfb..0fe4a08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,25 +16,25 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.schema-version="1.0" RUN apk --update --no-cache add \ - ca-certificates curl libressl nginx supervisor tzdata zip \ + curl supervisor tzdata zip \ && rm -rf /var/cache/apk/* /tmp/* ENV JLS_PATH="/opt/jetbrains-license-server" \ JLS_VERSION="15802" \ - JLS_SHA256="e0030be1fd06e2db19576363a388d8b84e7b33c9d48c54f0cfcdc032ddd96181" + JLS_SHA256="e0030be1fd06e2db19576363a388d8b84e7b33c9d48c54f0cfcdc032ddd96181" \ + USERNAME="docker" \ + UID=1000 GID=1000 ADD entrypoint.sh /entrypoint.sh ADD assets / -RUN mkdir -p "$JLS_PATH" "/data/registration" "/run/nginx" \ +RUN mkdir -p "$JLS_PATH" \ && curl -L "https://download.jetbrains.com/lcsrv/license-server-installer.zip" -o "/tmp/lsi.zip" \ && echo "$JLS_SHA256 /tmp/lsi.zip" | sha256sum -c - | grep OK \ && unzip "/tmp/lsi.zip" -d "$JLS_PATH" \ && rm -f "/tmp/lsi.zip" \ && chmod a+x "$JLS_PATH/bin/license-server.sh" \ && ln -sf "$JLS_PATH/bin/license-server.sh" "/usr/local/bin/license-server" \ - && ln -sf "/data/registration" "/root/.jb-license-server" \ - && touch "/data/access-config.json" \ && chmod a+x /entrypoint.sh EXPOSE 80 diff --git a/README.md b/README.md index fcb76b1..d8e7fb9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ If you are interested, [check out](https://hub.docker.com/r/crazymax/) my other ### Included -* Nginx reverse proxy * License server completely customizable via environment variables * Registration data and configuration in a single directory @@ -32,8 +31,11 @@ If you are interested, [check out](https://hub.docker.com/r/crazymax/) my other ### Environment variables +* `UID` : License server user id (default to `1000`) +* `GID` : License server group id (default to `1000`) * `TZ` : The timezone assigned to the container (default to `UTC`) -* `JLS_VIRTUAL_HOSTS` : [Virtual hosts](https://www.jetbrains.com/help/license_server/setting_host_and_port.html#d1010e63) where license server will be available (required ; comma delimited for several hosts) +* `JLS_VIRTUAL_HOSTS` : [Virtual hosts](https://www.jetbrains.com/help/license_server/setting_host_and_port.html#d1010e63) where license server will be available (comma delimited for several hosts) +* `JLS_CONTEXT` : [Context path](https://www.jetbrains.com/help/license_server/setting_host_and_port.html#d1010e63) used by the license server (default to : `/`) * `JLS_ACCESS_CONFIG` : JSON file to configure [user restrictions](https://www.jetbrains.com/help/license_server/configuring_user_restrictions.html) (default to `/data/access-config.json`) * `JLS_STATS_RECIPIENTS` : [Reports recipients](https://www.jetbrains.com/help/license_server/detailed_server_usage_statistics.html#d461e40) email addresses for stats (comma delimited) * `JLS_SMTP_SERVER` : SMTP server host to use for sending [stats](https://www.jetbrains.com/help/license_server/detailed_server_usage_statistics.html) (stats disabled if empty) @@ -49,7 +51,7 @@ If you are interested, [check out](https://hub.docker.com/r/crazymax/) my other ### Ports -* `80` : HTTP port +* `80` : Jetbrains License Server HTTP port ## Usage @@ -91,7 +93,7 @@ If you've got the following message : Passed value of header "Host" is not allowed. Please contact your license server administrator. ``` -That's because the license server is running behind the Nginx reverse proxy. Please configure virtual hosts using the `JLS_VIRTUAL_HOSTS` variable. +That's because the license server is running behind a reverse proxy. Please configure virtual hosts using the `JLS_VIRTUAL_HOSTS` variable. ## How can i help ? diff --git a/assets/etc/nginx/nginx.conf b/assets/etc/nginx/nginx.conf deleted file mode 100644 index 2e524d2..0000000 --- a/assets/etc/nginx/nginx.conf +++ /dev/null @@ -1,36 +0,0 @@ -daemon off; -user nginx; -error_log stderr error; - -events { - worker_connections 2048; - use epoll; -} - -http { - include mime.types; - default_type application/octet-stream; - - aio threads; - sendfile on; - keepalive_timeout 15; - keepalive_disable msie6; - keepalive_requests 100; - tcp_nopush on; - tcp_nodelay on; - server_tokens off; - gzip off; - - # https://www.jetbrains.com/help/license_server/configuring_secure_connection.html - server { - listen 80; - location / { - proxy_set_header X-Forwarded-Host $http_host; - proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Real-IP $remote_addr; - proxy_pass http://127.0.0.1:8080/; - } - } -} diff --git a/assets/etc/supervisord.conf b/assets/etc/supervisord.conf index bd09ea1..90df761 100644 --- a/assets/etc/supervisord.conf +++ b/assets/etc/supervisord.conf @@ -1,25 +1,21 @@ [supervisord] -nodaemon=true -pidfile=/var/run/supervisord.pid +nodaemon = true +user = root +logfile = /var/log/supervisord/supervisord.log +pidfile = /var/run/supervisord.pid +childlogdir = /var/log/supervisord/ +logfile_maxbytes = 50MB +logfile_backups = 10 +loglevel = info [supervisorctl] -serverurl=unix:///var/run/supervisor.sock +serverurl = unix:///var/run/supervisor.sock [unix_http_server] -file=/var/run/supervisor.sock +file = /var/run/supervisor.sock [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface -[program:license-server] -priority=1 -command=/usr/local/bin/license-server run -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -redirect_stderr=true - -[program:nginx] -command=/usr/sbin/nginx -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -redirect_stderr=true +[include] +files = /etc/supervisord/*.conf diff --git a/assets/etc/supervisord/license-server.conf b/assets/etc/supervisord/license-server.conf new file mode 100644 index 0000000..e4f1fa7 --- /dev/null +++ b/assets/etc/supervisord/license-server.conf @@ -0,0 +1,5 @@ +[program:license-server] +command = /usr/local/bin/license-server run +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 +redirect_stderr = true diff --git a/docker-compose.yml b/docker-compose.yml index 0fd3650..bd13e72 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,6 +39,7 @@ services: environment: - TZ=Europe/Paris - JLS_VIRTUAL_HOSTS=jetbrains-license-server.example.com,an-other-host.example.com + - JLS_CONTEXT=/ - JLS_ACCESS_CONFIG=/data/access-config.json - JLS_STATS_RECIPIENTS=webmaster@example.com,an-other-address@example.com - JLS_SMTP_SERVER=smtp.example.com diff --git a/entrypoint.sh b/entrypoint.sh index 8e038af..c49bb7e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,13 +1,32 @@ #!/bin/sh +TZ=${TZ:-"UTC"} JLS_PATH="/opt/jetbrains-license-server" -JLS_LISTEN_ADDRESS="127.0.0.1" -JLS_PORT=8080 +JLS_LISTEN_ADDRESS="0.0.0.0" +JLS_PORT=80 +JLS_CONTEXT=${JLS_CONTEXT:-"/"} JLS_ACCESS_CONFIG=${JLS_ACCESS_CONFIG:-"/data/access-config.json"} +# Timezone +echo "Setting timezone to ${TZ}..." +ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime +echo ${TZ} > /etc/timezone + +# Create docker user +echo "Creating ${USERNAME} user and group (uid=${UID} ; gid=${GID})..." +addgroup -g ${GID} ${USERNAME} +adduser -D -s /bin/sh -G ${USERNAME} -u ${UID} ${USERNAME} + +# Init +echo "Initializing files and folders..." +mkdir -p /data/registration /var/log/supervisord +ln -sf "/data/registration" "/root/.jb-license-server" +touch "/data/access-config.json" +chown -R ${USERNAME}. /data ${JLS_PATH} + # https://www.jetbrains.com/help/license_server/setting_host_and_port.html echo "Configuring Jetbrains License Server..." -license-server configure --listen ${JLS_LISTEN_ADDRESS} --port ${JLS_PORT} +license-server configure --listen ${JLS_LISTEN_ADDRESS} --port ${JLS_PORT} --context ${JLS_CONTEXT} # https://www.jetbrains.com/help/license_server/setting_host_and_port.html if [ ! -z "$JLS_VIRTUAL_HOSTS" ] ; then @@ -51,4 +70,8 @@ if [ ! -z "$JLS_STATS_TOKEN" ] ; then license-server configure --reporting.token ${JLS_STATS_TOKEN} fi +# Fix perms +echo "Fixing permissions..." +chown -R ${USERNAME}. /data ${JLS_PATH} + exec "$@"