Reputation: 41
So I got pycharm professional version. Its well worth it since I'm stuck with Windows atm, and pycharm is amazing, it helps me bypass all of the obstacles I run into wit Windows. The best tool I've come across. So the way I want to do the licensing thing is to create a server which will hold the license.
I want to do this with Docker
, create a docker container
which runs the server in the background. So in the tutorial I read, they recommend using Arch
linux as the linux server to run the license server. So thats what I did. But instead of using bare bones arch, I'm using the security upgraded version. Heres the base image I'm starting from:
nning2/compile-linux-grsec
So heres my Dockerfile so far:
FROM nning2/compile-linux-grsec
ENV APP_ROOT /app
ENV SERVER_DIR /opt/dvt-jb-lic-server
ENV SERVER_BINARY dvt-jb_licsrv.linux.amd64
ENV SERVER_BINARY_PATH "${SERVER_ROOT}/${SERVER_BINARY}"
ENV COMPOSE_CONVERT_WINDOWS_PATHS 1
RUN mkdir -p $APP_ROOT
WORKDIR $APP_ROOT
VOLUME [".:/app"]
ADD "./${SERVER_BINARY}" $APP_ROOT
RUN mkdir -p $SERVER_DIR
RUN cp "${APP_ROOT}/${SERVER_BINARY}" $SERVER_BINARY_PATH
RUN chmod +x $SERVER_BINARY_PATH
RUN ls -l $SERVER_DIR
RUN $SERVER_BINARY_PATH -mode install
So now I just need to make the docker-compose.yml
file to run the license server in the background. Heres what I got so far:
version: '2'
services:
shell:
build: .
command: /bin/bash service license-server
ports:
- "1337:1337"
When I run docker-compose build .
, heres what it outputs:
$ docker-compose build --force-rm --no-cache
Building shell
Step 1 : FROM nning2/compile-linux-grsec
---> baf47265c7fc
Step 2 : ENV APP_ROOT /app
---> Running in 77d33bfe8848
---> 67afb97c5b46
Removing intermediate container 77d33bfe8848
Step 3 : ENV SERVER_DIR /opt/dvt-jb-lic-server
---> Running in c1b0615d8bec
---> 1bc7ac4a8b78
Removing intermediate container c1b0615d8bec
Step 4 : ENV SERVER_BINARY dvt-jb_licsrv.linux.amd64
---> Running in be4210954aaa
---> ce48dd70acbb
Removing intermediate container be4210954aaa
Step 5 : ENV SERVER_BINARY_PATH "${SERVER_ROOT}/${SERVER_BINARY}"
---> Running in 9e1a0aa39855
---> a1c99aad2418
Removing intermediate container 9e1a0aa39855
Step 6 : ENV COMPOSE_CONVERT_WINDOWS_PATHS 1
---> Running in 2a9337698969
---> dae5eff0e382
Removing intermediate container 2a9337698969
Step 7 : RUN mkdir -p $APP_ROOT
---> Running in ffe6894f4d15
---> 2c9bfd607bc0
Removing intermediate container ffe6894f4d15
Step 8 : WORKDIR $APP_ROOT
---> Running in 5404c27b138c
---> a607eaed217e
Removing intermediate container 5404c27b138c
Step 9 : VOLUME .:/app
---> Running in ad577ac00c9e
---> 2fe4a66ba1ed
Removing intermediate container ad577ac00c9e
Step 10 : ADD "./${SERVER_BINARY}" $APP_ROOT
---> 5ec55e991fba
Removing intermediate container 55ae3d52227f
Step 11 : RUN mkdir -p $SERVER_DIR
---> Running in d76e590f011a
---> b379ef02ab88
Removing intermediate container d76e590f011a
Step 12 : RUN cp "${APP_ROOT}/${SERVER_BINARY}" $SERVER_BINARY_PATH
---> Running in 5e0d782f4549
---> 802eeb561b62
Removing intermediate container 5e0d782f4549
Step 13 : RUN chmod +x $SERVER_BINARY_PATH
---> Running in 64c79436824c
---> c67396e5a721
Removing intermediate container 64c79436824c
Step 14 : RUN ls -l $SERVER_DIR
---> Running in 0cda941ffc29
total 0
---> a94136235d9d
Removing intermediate container 0cda941ffc29
Step 15 : RUN $SERVER_BINARY_PATH -mode install
---> Running in d9bfeb3ae871
[91m2017/02/05 02:34:38 Installing license server as service.
2017/02/05 02:34:38 open /etc/init.d/JetBrainsLicServerDVT: no such file or directory
2017/02/05 02:34:38 Errors while installing the license server. Are you running this as root/Administrator?
[0m ---> a08092892872
Removing intermediate container d9bfeb3ae871
Successfully built a08092892872
So everything goes smoothly until it tries to install the binary. Its not installing the /etc/init.d/JetBrainsLicServerDVT
file for some reason. I'm new to Arch so don't know how administrator privileges work yet. I seem to have superuser privileges because I can copy the binary to the /opt directory and do various other things that would require superuser privileges.
I'm new to Arch
, on Ubuntu
I would use sudo
but I don't know if that works in Arch. Do I need to install the license server binary file with superuser privileges?
UPDATE: I logged into the container interactively to see whats happening. So it looks like this arch distro doesn't even have an /etc/init.d
directory. So installing this binary doesn't work. But when I just run the binary without any parameters:
[root@b140eac75b52 app]# ./dvt-jb_licsrv.linux.amd64
2017/02/05 03:18:50 Starting license server.
2017/02/05 03:18:50
_____ . +
_____ \ | : ,`
________\ |___________________ |____l____ _
/ . | | /___ \_|____/___
\___________\_|\ /` / / | /y!r
--------------``----\_____/ /\__________/ ------
____\ `~~~~----/ `----------` /____
\_____/( DVT JetBrains License Server v1.1 )\____/
2017/02/05 03:18:50 [!] Server running at: http://127.0.0.1:1337
2017/02/05 03:18:50 [!] Stop the license server with Ctrl+C
2017/02/05 03:18:50 [?] For advanced usage refer to --help
The server runs. I'd prefer to be able to install it properly so I can easily start and restart the service (i.e. with service start license-server
), but if it works, it works so I can't complain. I don't know why they insist on using arch when it doesn't actually install properly in arch.
So I decided to try creating the /etc/init.d
directory, then tried installing the binary again, and it worked:
[root@b140eac75b52 app]# mkdir /etc/init.d
[root@b140eac75b52 app]# ./dvt-jb_licsrv.linux.amd64 -mode install
2017/02/05 03:41:30 Installing license server as service.
2017/02/05 03:41:30 Successfully installed license server service.
And to make fully sure its working:
[root@b140eac75b52 app]# /etc/init.d/JetBrainsLicServerDVT restart
Stopping JetBrainsLicServerDVT..
Stopped
Starting JetBrainsLicServerDVT
Upvotes: 1
Views: 11122
Reputation: 1
You don't actually have to install it. You can just run it from ENTRYPOINT
docker-compose.yml
version: '2'
services:
license_server:
build: .
ports:
- "1337:1337"
Dockerfile
FROM alpine
WORKDIR /app
EXPOSE 1337
ADD ./dvt-jb_licsrv.linux.amd64 /app
RUN chmod +x /app/dvt-jb_licsrv.linux.amd64
ENTRYPOINT ["/app/dvt-jb_licsrv.linux.amd64"]
Upvotes: 0
Reputation: 41
EDIT: I thought this was the solution, but turns out its not. Firstly I can't run the container with /etc/init.d/license_server start
in the docker-compose.yml for some reason. When I check for running containers with docker ps
, there are no running containers. I can run the container with /bin/bash
by itself, and according to kitematic, the container is running and it should be accessible through the forwarded port:
https://i.gyazo.com/1de96b014cfbc78f4c188ec33f336519.png
But if I ping that IP and port, I get:
Ping request could not find host 192.168.99.100:1337. Please check the name and try again.
I'm using Docker with VirtualBox, and no forwarded ports show up for the VM. I tried adding them manual but that changed nothing.
The problem was that the /etc/init.d
folder didn't exist. So to fix it, I just created the folder, now the binary installs properly:
[root@b140eac75b52 app]# mkdir /etc/init.d
[root@b140eac75b52 app]# ./dvt-jb_licsrv.linux.amd64 -mode install
2017/02/05 03:41:30 Installing license server as service.
2017/02/05 03:41:30 Successfully installed license server service.
and now I can start, stop and restart the server easily:
[root@b140eac75b52 app]# /etc/init.d/JetBrainsLicServerDVT restart
Stopping JetBrainsLicServerDVT..
Stopped
Starting JetBrainsLicServerDVT
So the improved Dockerfile
is:
FROM nning2/compile-linux-grsec
ENV APP_ROOT /app
ENV SERVER_DIR /opt/dvt-jb-lic-server
ENV SERVER_BINARY dvt-jb_licsrv.linux.amd64
ENV SERVER_BINARY_PATH "${SERVER_ROOT}/${SERVER_BINARY}"
ENV COMPOSE_CONVERT_WINDOWS_PATHS 1
RUN mkdir -p $APP_ROOT
WORKDIR $APP_ROOT
VOLUME [".:/app"]
ADD "./${SERVER_BINARY}" $APP_ROOT
RUN mkdir -p $SERVER_DIR
RUN mv "${APP_ROOT}/${SERVER_BINARY}" $SERVER_BINARY_PATH
RUN chmod +x $SERVER_BINARY_PATH
RUN mkdir /etc/init.d
RUN $SERVER_BINARY_PATH -mode install
RUN mv "/etc/init.d/${SERVER_BINARY}" /etc/init.d/pycharm_license
and the docker-compose.yml
file:
version: '2'
services:
license_server:
environment:
ENV COMPOSE_CONVERT_WINDOWS_PATHS: 1
build: .
command: /bin/bash /etc/init.d/pycharm_license start
ports:
- "1337:1337"
NOTE: I changed the /etc/init.d
command name to something a bit easier to remember.
NOTE2: I'm new to Docker. I'd like to add this to the Docker hub since I spent a bit of time making it. But there are lots of things I don't know yet, like how to let users input configuration parameters (i.e. different users will need a different binary file).
If anyone wants to turn this into a Docker image and put it up on the hub, feel free to do so. I uploaded the gist
here:
https://gist.github.com/entheologist/42a6f6bb305897b16d1d1d6c4a9d7360
Upvotes: 1