0.1.57 ā€¢ Published 4 years ago

mxdocker v0.1.57

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

mxbuild.docker

logo

The MxBuild Docker helper utility consists of a CLI and Rest API interface for building MxBuild Dockers and Mendix Application Dockers. This tool focuses on Docker only, but uses the cloud foundry scripts provided by Mendix but is not only aimed at CF.

Quick Start - Dockerize Mendix App with pre-built MxBuild Docker

written for my good friend MO

Download a prebuilt Docker for the version of Mendix you want to support:

docker pull hgeldenhuys/mxbuild:6.10.10

Run the Docker Image:

docker run --rm --name=mx -v /homefolder/${MendixProjects}:/mx -p 3000:3000 -it hgeldenhuys/mxbuild:6.10.10

This is the server output:

.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.                    ##              .-.   .-..-.  .-.   .----. .-. .-..-..-.   .----. 
.              ## ##          ==     |  `.'  | \ \/ /    | {}  }| { } || || |   | šŸ”§  \
.           ## ##            ===     | |\ /| | / /\ \    | {}  }| {_} || || `--.|     /
.    /""""""""""""""""\___/ ===      `-' ` `-'`-'  `-'   `----' `-----'`-'`----'`----'  
.šŸŒŠšŸŒŠ{šŸŒŠšŸŒŠ šŸŒŠšŸŒŠšŸŒŠ šŸŒŠšŸŒŠšŸŒŠ šŸŒŠšŸŒŠ/ ==    Docker Helper Utility v1.0.0 Copyright 2019
.     \______ šŸ‘          __/         By Herman Geldenhuys
.       \    \        __/            
.        \____\______/
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
šŸŒ      Server is running at http://[::1]:3000

For performance reasons it is recommended to share 1 or 2 volumes with your docker. The first one containing the SVN checkouts of your project and the second a shared cache of dependencies downloaded from Mendix' CDN servers. This helps save us some time.

The Rest API will be listening on port 3000 on the localhost and will look for Mendix source applications in /mx

Open your browser on port 3000:

Restful API

Compile Mendix App

SVN Check out your Mendix Project into your ${MendixProjects} folder - ${SVNFolder}

Note1: Be sure to duplicate ${SVNFolder} to another folder if you intend on keeping the source after compilation. Typically inside a CI pipeline where you might want to run your integration test suite from the source folder. After compilation the SVN contents will be lost

Click explorer

Explorer

WARNING: this step replaces the SVN contents with a compiled version of the app. See Note 1

Select compile-mendix-app and enter the relative path to your ${SVNFolder} and click Execute

or run this curl command:

http://localhost:3000/compile-mendix-app?sourceFolderPath=${SVNFolder}

Now your folder content contains the compiled app:

āžœ  6.10.10 ls -l
total 96
drwxr-xr-x   3 mendix  staff     96 29 Oct 17:18 bin
drwxr-xr-x   4 mendix  staff    128 29 Oct 17:17 data
drwxr-xr-x   2 mendix  staff     64 29 Oct 17:17 database
drwxr-xr-x  22 mendix  staff    704 29 Oct 16:23 lib
drwxr-xr-x   2 mendix  staff     64 29 Oct 17:17 log
drwxr-xr-x   8 mendix  staff    256 29 Oct 17:16 model
drwxr-xr-x@  6 mendix  staff    192 26 Mar  2019 nginx
drwxr-xr-x   3 mendix  staff     96 29 Oct 17:17 runtimes
-rw-r--r--@  1 mendix  staff    133 26 Mar  2019 sources.yml
-rwxr-xr-x   1 mendix  staff  42495 29 Oct 17:18 start.py
drwxr-xr-x  22 mendix  staff    704 29 Oct 17:16 web

Stage Docker dependencies

Move the ${SVNFolder} to a sub-folder called project in your docker staging folder aka ${DockerStagingFolder}.:

āžœ  mkdir -p project
āžœ  mv ./* project/ 2> /dev/null
āžœ  ls -l
total 0
drwxr-xr-x  16 mendix  staff  512 29 Oct 17:31 project

Now run the http://localhost:3000/stage-mendix-dockerfile API Rest end point, specifying the docker-staging-folder, image-name and image-tag. Specify the return-constants-defaults if you want a template of the project constants in JSON format for later use: stage-docker-files

or this curl command:

curl -X GET "http://localhost:3000/stage-mendix-dockerfile?docker-staging-folder=`${DockerStagingFolder}`&image-name=${DockerImageName}&image-tag=latest&return-constants-defaults=false" -H "accept: */*"

This is the output server-side (given you are using a cache-path previously used):

.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.                    ##              .-.   .-..-.  .-.   .----. .-. .-..-..-.   .----. 
.              ## ##          ==     |  `.'  | \ \/ /    | {}  }| { } || || |   | šŸ”§  \
.           ## ##            ===     | |\ /| | / /\ \    | {}  }| {_} || || `--.|     /
.    /""""""""""""""""\___/ ===      `-' ` `-'`-'  `-'   `----' `-----'`-'`----'`----'  
.šŸŒŠšŸŒŠ{šŸŒŠšŸŒŠ šŸŒŠšŸŒŠšŸŒŠ šŸŒŠšŸŒŠšŸŒŠ šŸŒŠšŸŒŠ/ ==    Docker Helper Utility v1.0.0 Copyright 2019
.     \______ šŸ‘          __/         By Herman Geldenhuys
.       \    \        __/            
.        \____\______/
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
šŸŒ      Server is running at http://[::1]:3000
stage-mendix-docker-files --serve-verbose --deployment-folder="/mx/6.10.10" --json  --cache-folder=/tmp/docker1 --name=myapp --tag=latest
šŸ¦‘      already have MXBuild
šŸ¦‘      already have Runtime
šŸ¦‘      already have Mono   
šŸ¦‘      already have JDK    
šŸ¦‘      already have JRE    
šŸ™      updating repo /tmp/docker1/buildpack...

In the browser this is your response JSON:

{
  "runtimeVersion": "6.10.10",
  "projectName": "6.10.10",
  "buildContext": "/Users/mendix/Mendix/6.10.10",
  "buildCommand": "docker build --no-cache -f Dockerfile.deploy -t myapp:latest .",
  "runCommand": "docker run --rm -d -e ADMIN_PASSWORD={yourAdminPwd} -e CONSTANTS={yourEnvJson} -e DATABASE_ENDPOINT={yourJDBCString} [--link postgres:postgres] -p 8081:8081 -p 8080:8080 myapp:latest",
  "hint": "Generate the Constants using this utility, and then store in a secret that transforms it at run into an environment variable argument."
}

Now you can cd to the buildContext and execute the buildCommand and then the runCommand as examples. Just replace the values in the variables between curly braces with your own jdbc connection url, test constants or production constants passed via a secret and link to other dockers as needed.

Microflow Constants

When you launch your Mendix Docker, your microflow constants are passed as a JSON string as an environment variable called CONSTANTS. The MxBuild utility also provides you with a handy way of converting an existing settings.yaml and extracting your constants in JSON.

Just point the Rest API to the settings.yaml or m2ee.yaml file and either return the entire YAML or just the Constants section by setting the microflowConstantsOnly to true.

For example if you pointed your API to /somefolder/m2ee-tools-master/examples/m2ee.yaml

or used this curl command:

curl -X POST "http://localhost:3000/convert-yaml-to-json?path=%2Fsomefolder%2Fm2ee-tools-master%202%2Fexamples%2Fm2ee.yaml&microflowConstantsOnly=true" -H "accept: */*"

the output would be:

{"Module.Constant": "text","AnotherModule.AnotherConstant": "bla"}

For example, running the previous run command:

docker run --rm -d -e ADMIN_PASSWORD=Complicated.Password1 -e CONSTANTS='{"Module.Constant": "text","AnotherModule.AnotherConstant": "bla"}' -e DATABASE_ENDPOINT=postgres://mendix:mendix@postgres:5432/mendix --link postgres:postgres -p 8081:8081 -p 8080:8080 myapp:latest"

Links

Pre-built dockers

Supported Mendix Versions

  • 6.10.10
  • 6.10.18
  • 8.1.1.58432

Github NPM

0.1.57

4 years ago

0.1.56

4 years ago

0.3.11

4 years ago

0.3.10

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.21

4 years ago

0.2.20

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.12

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.33

4 years ago

0.1.32

4 years ago

0.1.54

4 years ago

0.1.53

4 years ago

0.1.51

4 years ago

0.1.50

4 years ago

0.1.37

4 years ago

0.1.36

4 years ago

0.1.35

4 years ago

0.1.34

4 years ago

0.1.31

4 years ago

0.1.30

4 years ago

0.1.29

4 years ago

0.1.28

4 years ago

0.1.23

4 years ago

0.1.22

4 years ago

0.1.21

4 years ago