|
| 1 | +# Upgrading from Docker Buildpack v5 |
| 2 | + |
| 3 | +Docker Buildpack v6 contains a breaking change and might require some changes in your CI/CD pipeline: |
| 4 | + |
| 5 | +Building Mendix projects from source (\*.mpr or \*.mpk files) is now done using a build.py script. |
| 6 | +If your CI/CD pipeline uses Docker Buildpack to build \*.mda files (compiled Mendix apps), no further changes are needed. |
| 7 | + |
| 8 | +If you're upgrading from Docker Buildpack v4 (or an older version), you'll also need to follow the [upgrading from Docker Buildpack v4](upgrading-from-v4.md) instructions. |
| 9 | + |
| 10 | +## Using the build.py script |
| 11 | + |
| 12 | +Docker Buildpack v6 no longer uses CF Buildpack to compile MPR (or MPK) files - to continue supporting newer versions of Mendix, Java and the base OS. |
| 13 | +Instead, a custom `build.py` script will: |
| 14 | + |
| 15 | +1. Prepare a clean [Docker context](https://docs.docker.com/build/concepts/context/) in the path specified by `--destination`. All files required to build the app image will be copied to this destination. |
| 16 | +2. Detect the file type of the source path specified by the `--source` arg (an MPK file, an MPR file, an MDA file or an unpacked MDA directory). |
| 17 | +3. If necessary (`--source` specifies project that needs to be compiled) |
| 18 | + 1. Create an image containing [mxbuild](https://docs.mendix.com/refguide/mxbuild/) and its dependencies. |
| 19 | + 2. Run an `mxbuild` in a container, and copy the resulting MDA contents to the destination path specified by `--destination`. |
| 20 | +4. Otherwise (`--source` specifies a path to an MDA file or unpacked MDA directory), `build.sh` will just copy the MDA contents to the destination path specified by `--destination`. |
| 21 | + |
| 22 | +Once the `build.py` script runs successfully, the path specified by `--destination` will contain a Docker context and everything needed to run a `docker build` command. |
| 23 | + |
| 24 | +### Updating an existing pipeline to use build.py |
| 25 | + |
| 26 | +There instructions are provided as a reference, based on a typical pipeline. Your CI/CD pipeline might be different - for support with updating a custom pipeline, please check the [Mendix Support Policy](https://www.mendix.com/evaluation-guide/evaluation-learning/support/). |
| 27 | + |
| 28 | +1. Verify your pipeline image or runner has Python 3.8 available, and uses a UNIX-like operating system (Linux, macOS or Windows Subsystem for Linux). |
| 29 | +2. Locate the `docker build` step in your CI/CD pipeline that builds the app image. This should be the step that builds the Mendix app, and not the rootfs or its dependencies. Any `docker build` commands that build the rootfs should not be changed. |
| 30 | +3. Before the `docker build` step, add the following lines (replacing `<path-to-source>` with the path to the project source, and `<destination-dir>` with an empty/temporary writable path): |
| 31 | + ```shell |
| 32 | + ./build.py --source <path-to-source> --destination <destination-dir> build-mda-dir |
| 33 | + ``` |
| 34 | +4. In the `docker build` step: |
| 35 | + * Remove `--build-arg BUILD_PATH` args. |
| 36 | + * Remove `-f` and `--file` args specifying a Dockerfile, if they exist. |
| 37 | + * Update the [Docker context](https://docs.docker.com/build/concepts/context/) path to the `<destination-dir>`. |
| 38 | + |
| 39 | +After the update, your pipeline might look like this: |
| 40 | + |
| 41 | +```shell |
| 42 | +# Preparation steps |
| 43 | +# Downloag Docker Buildpack |
| 44 | +DOCKER_BUILDPACK_VERSION=v6.0.0 |
| 45 | +curl -LJ -o - https://github.com/mendix/docker-mendix-buildpack/archive/refs/tags/${DOCKER_BUILDPACK_VERSION}.tar.gz | tar --strip-components=1 -xvz |
| 46 | +# Checkout the Mendix app source |
| 47 | +git clone <mendix-app-git> mendix-app-src |
| 48 | +# Build the Mendix app from mendix-app-src to a temporary location |
| 49 | +./build.py --source mendix-app-src --destination /tmp/docker-buildpack-context build-mda-dir |
| 50 | +# Prepare and push the Docker image, using /tmp/docker-buildpack-context as the Docker context |
| 51 | +docker build --tag example.com/mendix-app:latest /tmp/docker-buildpack-context |
| 52 | +docker push example.com/mendix-app:latest |
| 53 | +# Follow-up steps |
| 54 | +``` |
| 55 | + |
| 56 | +# Other changes |
| 57 | + |
| 58 | +Docker Buildpack v6 switched from `ubi8` to `ubi9` images ([Red Hat Universal Base Images](https://developers.redhat.com/articles/ubi-faq) whenever possible. |
| 59 | +Building Mendix 8 and 9 apps still uses `ubi8`, as those versions depend on an older version of Mono that doesn't work in newer operating systems. |
0 commit comments