Add JLS_CONTEXT env var

Ability to set a custom UID / GID
Timezone was not setted
No need of Nginx
Error while saving stats
This commit is contained in:
CrazyMax 2018-02-15 16:52:47 +01:00
parent d57796dbcf
commit 45a1cc0557
8 changed files with 63 additions and 64 deletions

View File

@ -1,5 +1,13 @@
# Changelog # 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) ## 15802-RC1 (2018/02/01)
* Initial version based on JetBrains License Server 15802 * Initial version based on JetBrains License Server 15802

View File

@ -16,25 +16,25 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.schema-version="1.0" org.label-schema.schema-version="1.0"
RUN apk --update --no-cache add \ RUN apk --update --no-cache add \
ca-certificates curl libressl nginx supervisor tzdata zip \ curl supervisor tzdata zip \
&& rm -rf /var/cache/apk/* /tmp/* && rm -rf /var/cache/apk/* /tmp/*
ENV JLS_PATH="/opt/jetbrains-license-server" \ ENV JLS_PATH="/opt/jetbrains-license-server" \
JLS_VERSION="15802" \ JLS_VERSION="15802" \
JLS_SHA256="e0030be1fd06e2db19576363a388d8b84e7b33c9d48c54f0cfcdc032ddd96181" JLS_SHA256="e0030be1fd06e2db19576363a388d8b84e7b33c9d48c54f0cfcdc032ddd96181" \
USERNAME="docker" \
UID=1000 GID=1000
ADD entrypoint.sh /entrypoint.sh ADD entrypoint.sh /entrypoint.sh
ADD assets / 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" \ && 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 \ && echo "$JLS_SHA256 /tmp/lsi.zip" | sha256sum -c - | grep OK \
&& unzip "/tmp/lsi.zip" -d "$JLS_PATH" \ && unzip "/tmp/lsi.zip" -d "$JLS_PATH" \
&& rm -f "/tmp/lsi.zip" \ && rm -f "/tmp/lsi.zip" \
&& chmod a+x "$JLS_PATH/bin/license-server.sh" \ && chmod a+x "$JLS_PATH/bin/license-server.sh" \
&& ln -sf "$JLS_PATH/bin/license-server.sh" "/usr/local/bin/license-server" \ && 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 && chmod a+x /entrypoint.sh
EXPOSE 80 EXPOSE 80

View File

@ -19,7 +19,6 @@ If you are interested, [check out](https://hub.docker.com/r/crazymax/) my other
### Included ### Included
* Nginx reverse proxy
* License server completely customizable via environment variables * License server completely customizable via environment variables
* Registration data and configuration in a single directory * 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 ### 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`) * `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_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_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) * `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 ### Ports
* `80` : HTTP port * `80` : Jetbrains License Server HTTP port
## Usage ## 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. 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 ? ## How can i help ?

View File

@ -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/;
}
}
}

View File

@ -1,6 +1,12 @@
[supervisord] [supervisord]
nodaemon = true nodaemon = true
user = root
logfile = /var/log/supervisord/supervisord.log
pidfile = /var/run/supervisord.pid pidfile = /var/run/supervisord.pid
childlogdir = /var/log/supervisord/
logfile_maxbytes = 50MB
logfile_backups = 10
loglevel = info
[supervisorctl] [supervisorctl]
serverurl = unix:///var/run/supervisor.sock serverurl = unix:///var/run/supervisor.sock
@ -11,15 +17,5 @@ file=/var/run/supervisor.sock
[rpcinterface:supervisor] [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:license-server] [include]
priority=1 files = /etc/supervisord/*.conf
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

View File

@ -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

View File

@ -39,6 +39,7 @@ services:
environment: environment:
- TZ=Europe/Paris - TZ=Europe/Paris
- JLS_VIRTUAL_HOSTS=jetbrains-license-server.example.com,an-other-host.example.com - JLS_VIRTUAL_HOSTS=jetbrains-license-server.example.com,an-other-host.example.com
- JLS_CONTEXT=/
- JLS_ACCESS_CONFIG=/data/access-config.json - JLS_ACCESS_CONFIG=/data/access-config.json
- JLS_STATS_RECIPIENTS=webmaster@example.com,an-other-address@example.com - JLS_STATS_RECIPIENTS=webmaster@example.com,an-other-address@example.com
- JLS_SMTP_SERVER=smtp.example.com - JLS_SMTP_SERVER=smtp.example.com

View File

@ -1,13 +1,32 @@
#!/bin/sh #!/bin/sh
TZ=${TZ:-"UTC"}
JLS_PATH="/opt/jetbrains-license-server" JLS_PATH="/opt/jetbrains-license-server"
JLS_LISTEN_ADDRESS="127.0.0.1" JLS_LISTEN_ADDRESS="0.0.0.0"
JLS_PORT=8080 JLS_PORT=80
JLS_CONTEXT=${JLS_CONTEXT:-"/"}
JLS_ACCESS_CONFIG=${JLS_ACCESS_CONFIG:-"/data/access-config.json"} 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 # https://www.jetbrains.com/help/license_server/setting_host_and_port.html
echo "Configuring Jetbrains License Server..." 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 # https://www.jetbrains.com/help/license_server/setting_host_and_port.html
if [ ! -z "$JLS_VIRTUAL_HOSTS" ] ; then if [ ! -z "$JLS_VIRTUAL_HOSTS" ] ; then
@ -51,4 +70,8 @@ if [ ! -z "$JLS_STATS_TOKEN" ] ; then
license-server configure --reporting.token ${JLS_STATS_TOKEN} license-server configure --reporting.token ${JLS_STATS_TOKEN}
fi fi
# Fix perms
echo "Fixing permissions..."
chown -R ${USERNAME}. /data ${JLS_PATH}
exec "$@" exec "$@"