Dockerize Yarkon Server using EC2
Setting up the docker version of Yarkon Server is a simple process that should get you up and running in minutes.
The following guide describes the process using an EC2 running Ubuntu, but it should work the same for any docker capable host.
Important Notes
-
Yarkon Server is available as a public image from Docker Hub. It comes pre-set with a 30 day free trial for up to 10 users. No registration is required.
-
In this example, we use
sudo
for all installation steps. This is the quick and easy way to get things going on an EC2 running a *nix OS, but if you want to use this solution long term, make sure to follow the post installation steps. -
For the purpose of illustration, we use
docker-compose
here, but do note that this is a quick and simple example. To be able to run docker continuously in a production environment, you'd have to set it up properly. If you do choose to usedocker-compose
, make sure to review the detailed documentation from Docker.
Step 1 - Launch an EC2 instance
Yarkon would work on practically any instance type, with any OS that supports docker. For the purpose of this guide, we launched a t3.nano instance with 8 GB of disk space, running Ubuntu 18.04 (a popular and free option). As you can see, the requirements for Yarkon are very low, as far as CPU and storage are concerned.
When writing this document, we used Ubuntu Server 18.04 LTS (HVM), SSD Volume Type, ami-085925f297f89fce1.
Step 2 - Set up docker
Once the instance is up, SSH into it, and install the docker engine. We followed the instructions in this document from Docker. If you are using a different OS, locate the appropriate document.
Correct for the time this guide was written, the following steps got it done:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
The last step verifies that docker is properly installed.
Step 3 - Install docker-compose
You should use your preferred method for running docker containers. For this guide, we chose to use docker-compose
, so we also need to install it as following:
sudo apt install docker-compose
Step 4 - Add the docker-compose file
Next we created a dedicated folder for Yarkon, and added our docker-compose.yml
file.
mkdir yarkon && cd yarkon
nano docker-compose.yml
And we simply paste the content of this file into the editor, taking care to put valid AWS credentials there. See the IAM guide for more on credentials.
version: "3.2"
# We use "xyz" to denote the version number used. For instance, if you are using
# yarkon version 4.5.1, "xyz" would be "451". You can use another naming convention
# if you prefer. Explicitely definding the version number in the image tag and
# volumes ensures that upgrades can be done sequentially and you can always restore
# to a previous version.
services:
server:
image: "yarkon/server:x.y.z" # Use the correct tag here
ports:
# Map the port of the host to the one used by Yarkon
- "80:8000"
environment:
# When running in AWS, the preferred way to provide AWS API keys to the
# container is through using an IAM machine role. If this cannot be done,
# or when running it outside of AWS, you can pass credentials here:
AWS_ACCESS_KEY_ID: "EXAMPLERFP4S3EXAMPLE"
AWS_SECRET_ACCESS_KEY: "examplexcRA2gvPBPKAmt95yWIwz/vJIJexample"
AWS_REGION: "us-east-1"
# The provider name defaults to AWS, but you can change it to something
# your users might find more recognizable. In the client, it is displayed
# above the buckets and in the About form.
PROVIDER_NAME: "My Company"
volumes:
- dbdata_xyz:/var/app/current/database
- yarkon_xyz:/var/app/current/public/yarkon
- license:/var/app/current/.lic
- /var/log:/var/app/current/log # Map the /var/log folder on the host to the log folder
volumes:
dbdata_xyz:
yarkon_xyz:
license:
Step 5 - Start it up
All that is left to do is to start the container, docker will take care of the rest. To do so, simply execute this command:
sudo docker-compose up -d
It is important to run
docker-compose
with the-d
(detach) flag, since it will be running under the root account. You can avoid this issue if you complete the optional step documented here.
Step 6 - Set up Yarkon Server
Using your favorite browser, go to the public DNS of your EC2 instance; you can get it from the AWS dashboard, it would be something like http://ec2-54-174-210-49.compute-1.amazonaws.com/, with its own IP of course.
At this point, the Setup form for Yarkon Server would be displayed. Put in your details and once confirmed, your server is ready to go.
Step 7 - Check the logs
You can view Yarkon logs from the browser, but since we are running with docker, the logs are also visible from the terminal, as well as thr /var/log/
folder which was mapped in the docker-compose.yml
config file. Go back to the instance, and verify that the logs looks like the following:
Creating network "yarkon_default" with the default driver
Creating volume "yarkon_yarkon" with default driver
Creating volume "yarkon_dbdata" with default driver
Creating volume "yarkon_license" with default driver
Pulling server (yarkon/server:latest)...
latest: Pulling from yarkon/server
6ae821421a7d: Pull complete
f0d1c6739de6: Pull complete
2f38d92cd251: Pull complete
88779aba9e9b: Pull complete
2f1d61215c2a: Pull complete
21cc550c0bab: Pull complete
b9969ac51d40: Pull complete
b59e3a6c6bad: Pull complete
Digest: sha256:7137993487ddb974ea971edbfb090d25ae32d2db7faae9f2ec50f25c8c348c9f
Status: Downloaded newer image for yarkon/server:latest
Creating yarkon_server_1 ...
Creating yarkon_server_1 ... done
Attaching to yarkon_server_1
server_1 | 2020-04-30T00:07:02: PM2 log: Launching in no daemon mode
server_1 | 2020-04-30T00:07:02: PM2 log: App [Yarkon Admin Console:0] starting in -fork mode-
server_1 | 2020-04-30T00:07:02: PM2 log: App [Yarkon Admin Console:0] online
server_1 | [00:07:03] INFO Connecting to sqlite DB: database/aphek.db:aphek
server_1 | [00:07:03] INFO
server_1 | [00:07:03] INFO ,-------------------------------------------------------------------.
server_1 | [00:07:03] INFO | |
server_1 | [00:07:03] INFO | |
server_1 | [00:07:03] INFO | ## ## ### ######## ## ## ####### ## ## |
server_1 | [00:07:03] INFO | ## ## ## ## ## ## ## ## ## ## ### ## |
server_1 | [00:07:03] INFO | #### ## ## ## ## ## ## ## ## #### ## |
server_1 | [00:07:03] INFO | ## ## ## ######## ##### ## ## ## ## ## |
server_1 | [00:07:03] INFO | ## ######### ## ## ## ## ## ## ## #### |
server_1 | [00:07:03] INFO | ## ## ## ## ## ## ## ## ## ## ### |
server_1 | [00:07:03] INFO | ## ## ## ## ## ## ## ####### ## ## |
server_1 | [00:07:03] INFO | |
server_1 | [00:07:03] INFO | Yarkon Admin Console |
server_1 | [00:07:03] INFO | Enterprise Edition v4.5.1 |
server_1 | [00:07:03] INFO | |
server_1 | [00:07:03] INFO | Environment: production (packaged) |
server_1 | [00:07:03] INFO | Port: 8000 |
server_1 | [00:07:03] INFO | Server: /console |
server_1 | [00:07:03] INFO | Client: / |
server_1 | [00:07:03] INFO | Database: database/aphek.db:aphek |
server_1 | [00:07:03] INFO | |
server_1 | [00:07:03] INFO | |
server_1 | [00:07:03] INFO `-------------------------------------------------------------------'
server_1 | [00:07:03] INFO
server_1 | [00:07:03] INFO Initializing session using sequelize (db backed) store.
server_1 | [HPM] Proxy created: / -> s3.amazonaws.com
server_1 | [00:07:20] INFO Initializing application
server_1 | [00:07:25] INFO Using key-file license provider
server_1 | [00:07:25] INFO Get instance data for company 1
server_1 | [00:07:25] INFO Verifying license for instance 02:42:ac:12:00:02 and company 1
server_1 | [00:07:25] INFO Getting details of license file for company 1
server_1 | [00:07:25] WARN Failed getting app data. TypeError: Cannot read property 'features' of null
server_1 | [00:07:27] INFO Initialization done. Starting server.
server_1 | [00:07:51] INFO <no user> GET / 302 58 - 20.539 ms
server_1 | [00:07:52] INFO <no user> GET /setup/ 200 - - 287.618 ms
Step 8 - Turn the server off
When you are done, you can turn the Yarkon Server off by terminating the instance. Do it from the yarkon
folder using this command:
sudo docker-compose down