Docker Distribution

1. Setup Docker Registry

Prerequisites

A virtual private server with Ubuntu 18.04

A domain for Docker Registry, and set a A record point to the vps address

Installation

wget https://raw.githubusercontent.com/vlinx-io/docker-utils/master/scripts/docker-install.sh
wget https://raw.githubusercontent.com/vlinx-io/docker-utils/master/scripts/registry-deploy.sh
chmod +x docker-install.sh registry-deploy.sh
./docker-install.sh
./registry-deploy.sh

Follow the prompts to complete the installation

2. Setup Docker Node

Setup Docker Node on the machine that need to deploy apps

Install Docker on Ubuntu 18.04

wget https://raw.githubusercontent.com/vlinx-io/docker-utils/master/scripts/docker-install.sh
chmod +x docker-install.sh
./docker-install.sh

Launch Docker Node

wget https://protector4j.com/resources/pub/docker-node.tar.gz
tar -xzf docker-node.linux64.tar.gz
cd docker-node
./docker-node

it will launch a docker node service, and listen on the 15399 port

3. Encrypt apps by Protector4J

Download latest protector4j from https://protector4j.com/download.html

Encrypt and generate the app for Linux64

On the output page, select Linux-64 as the target platform, the app for docker should be the linux64 app.

The final app will be in output-folder/linux64

4. Install Docker on local machine

For Ubuntu 18.04

wget https://raw.githubusercontent.com/vlinx-io/docker-utils/master/scripts/docker-install.sh
chmod +x docker-install.sh
./docker-install.sh

For macOS

Refer to this article https://docs.docker.com/docker-for-mac/install/

Login Docker Registry

docker login domain-of-docker-registry

5. Push app by DockerNexus

Download DockerNexus

macOS: https://protector4j.com/resources/pub/docker-nexus.mac.tar.gz

Linux: https://protector4j.com/resources/pub/docker-nexus.linux64.tar.gz

Configure app

Extract the archive, find the app config file in docker-nexus/config-files folder, copy and modify a new one according to your app type

# the name for the app
appName: ''
# the version of the app,
appVersion: ''
# the maintainer, eg vlinx (vlinx@vlinx.io)
maintainer: ''
# this is the output folder of protector4j
# it can be the output folder
# if you selected the linux-64 platform, if should be output-folder/linux64
appFolder: ''
# for glassfish, please type glassfish-5
# for payara, please type payara-5
serverVersion: ''
# the registry of docker that you just setup.
# it should be the domain of the registry, eg hub.vlinx.io
registry: ''
# the docker node host that you just setup,
# the value can be like ip:15399, the defaut port is 15399
dockerNodeHost: ''
# the communication password with the docker node, the default values is abc*123
dockerNodeCommPwd: ''
environment: {}
# the port map of host and docker container
# left value is the port of host, the right value is the port of docker container
# eg: ports:['18080:8080','14848:4848']
ports: []
# the volumes map fo docker container and the host
# eg: volumes: ['/work/logs:payara/glassfish/domains/domain1/logs']
# it will mount 'payara/glassfish/domains/domain1/logs' in docker container to
# '/work/logs' in the host machine
# left value is the absolute path of the host,
# and the right value is the relative path to the output folder
volumes: []
restart: always

Push the app

./docker-nexus -t glassfish -f app-config-file

it will push the app to the docker node.

After the deployment, you can visit the app by the http://ip:port

6. About database

Because of It's just a test version, we don't include the database component this time. If you need to access the database, you need to set up another database server. If you usually access the local database, you can't use 127.0.0.1 to visit the database in the docker container, you should use the real address of the docker host.