██████╗ ██████╗ ██████╗██╗ ██╗██╗ ██╗██╗
██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██║ ██║██║
██║ ██║██║ ██║██║ █████╔╝ ██║ ██║██║
██║ ██║██║ ██║██║ ██╔═██╗ ██║ ██║██║
██████╔╝╚██████╔╝╚██████╗██║ ██╗╚██████╔╝██║
╚═════╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚═
Build a Pluggable Web Experience from multiple Docker Based Micro Apps
This is an experiment and has no formal support. Feel free to fork it for your own use. There are plenty of READMEs and tests amongst the source code to give an idea of whats going on. License is the http://unlicense.org
$ git clone https://github.com/yoosername/dockui.git
$ cd dockui
$ npm install
$ docker build --tag dockui/instance --file Dockerfile-Dev .
docker network create dockui
Start a new framework instance node (in DEV_MODE uses Nodemon and persistant in memory db with LokiJS)
$ docker run -it \
--env DOCKUI_WEB_PORT=3000 \
--env DOCKUI_STORE_TYPE=lokijs \
--env DOCKUI_STORE_DB_FILENAME=/app/loki.db \
--env DOCKUI_DOCKER_APP_SELECTOR=DOCKUI_APP \
--network dockui
-p 3000:3000 \
-v $(pwd):/app \
-v /var/run/docker.sock:/var/run/docker.sock \
dockui/instance
...
To connect a CLI to this instance first run:
export DOCKUI_INSTANCE=http://localhost:3000
...
npm install -g https://github.com/yoosername/dockui.git
$ dockui run
...
[ INFO][2019-07-16T18:50:45.590Z][..........AppService] : App Service has started
[ INFO][2019-07-16T18:50:45.595Z][.........TaskManager] : Task Manager has started
[ INFO][2019-07-16T18:50:45.631Z][..........WebService] : Web Service has started at http://localhost:8080/
[ INFO][2019-07-16T18:50:45.631Z][..........WebService] :
To connect a CLI to this instance first run:
export DOCKUI_INSTANCE=http://localhost:8080
...
To end a running DockUI instance send a SIGTERM (e.g. Ctrl->C on Linux)
DockUI is intended for running in the foreground in Docker Containers however to run as daemon on a host you can use something like PM2
The output from the run command gives you the env var required to point the CLI at a particular instance For example:
export DOCKUI_INSTANCE=http://localhost:3000
export NODE_TLS_REJECT_UNAUTHORIZED=0
$ dockui ls
┌──────────────────────┬──────────────┬──────────────────────┬─────────┬────────────┐
│ App │ Id │ Key │ Enabled │ Permission │
├──────────────────────┼──────────────┼──────────────────────┼─────────┼────────────┤
│ DockUI Dashboard App │ ce4bfd7dd549 │ dockui.dashboard.app │ true │ admin │
└──────────────────────┴──────────────┴──────────────────────┴─────────┴────────────┘
Apps can be loaded from a variety of locations through the use of AppLoaders. Built in ones include:
- Manually using CLI to load from URL
- Detection of Docker container using Docker events
- Manually using CLI to load from Git Repo (using Dockerfile and openshift source2image)
- Remotely by an App using Management REST API with shared creds
- The Managing App must have originally been loaded via the CLI
- The Managing App must be currently Enabled
- The Managing App must have been granted ADMIN permission
$ dockui load --permission admin http://localhost:3000/demo/demo.app.yml
ce4bfd7dd549bf16a1705ab5a221609d8cd67a5264cc3ce467dc443ce1701108
TODO: Use https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
$ dockui load --permission read --strategy sti https://github/yoosername/dockui-app-nodejs-demo
...
$ dockui load --permission write --strategy docker-image dockui/demoapp
...
$ git clone https://github/yoosername/dockui-app-demo
$ cd dockui-app-demo
$ npm install
$ docker build -t dockui/app-demo --file Dockerfile-Dev .
$ docker run -it --env HTTP_PORT=3333 --env HTTP_SCHEME=http -p 3333:3333 -v $(pwd):/app --network dockui --label DOCKUI_APP=true --label DOCKUI_DESCRIPTOR=demo.app.yml dockui/app-demo
The Label to indicate that this docker container should be considered a dockui App is determined by what you set in the instance environment e.g. "--env DOCKUI_DOCKER_APP_SELECTOR=DOCKUI_APP"
At this point in the logs for the instance you should see the loading occur
When Apps are auto loaded they are disabled by default. you must manually enable them.
Note: Use the hash of the previously loaded app as the argument to this command
$ dockui enable ce4bfd7dd549
Now you can visit http://localhost:3000 to see the loaded app and the modules it provides
The App Descriptor can be either in JSON or YAML format. It describes information about the App and what it provides to give the installer a clue, lifecyle callbacks for the framework and App to setup secure communication and a list of the various Module types which the App is contributing to the overall Application.
See Reference here: Descriptor Reference
See API here: API.md
See TESTS here: TESTS.md
One codebase tracked in revision control, many deploys
Explicitly declare and isolate dependencies
Store config in the environment
Treat backing services as attached resources
Strictly separate build and run stages
Execute the app as one or more stateless processes
Export services via port binding
Scale out via the process model
Maximize robustness with fast startup and graceful shutdown
Keep development, staging, and production as similar as possible
Treat logs as event streams
Run admin/management tasks as one-off processes