Skip to content

Commit b7607f2

Browse files
authored
Merge pull request #163 from mendix/DES-4896_replace-ubuntu-with-ubi8
DES-4896 Replace Ubuntu with ubi8
2 parents cfd2912 + 0a530ce commit b7607f2

18 files changed

+215
-221
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,15 @@ on:
99
branches: [ master ]
1010

1111
jobs:
12-
test-default:
13-
name: Test with default parameters
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
18-
- uses: actions/checkout@v2
19-
20-
# Run the integration test script
21-
- name: Run integration tests
22-
run: sh ./.integrationtest.sh
23-
24-
test-bionic:
25-
name: Test with a bionic rootfs
26-
runs-on: ubuntu-latest
27-
28-
steps:
29-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
30-
- uses: actions/checkout@v2
31-
32-
# Switch to Ubuntu Bionic rootfs
33-
- name: Switch to Ubuntu Bionic rootfs
34-
run: |
35-
echo -n "mendix/rootfs:bionic" > rootfs.version
36-
echo -n "bionic" > docker-buildpack.version
37-
38-
# Run the integration test script
39-
- name: Run integration tests
40-
run: sh ./.integrationtest.sh
4112

4213
test-ubi8:
4314
name: Test with a ubi8 rootfs
4415
runs-on: ubuntu-latest
4516

4617
steps:
4718
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
48-
- uses: actions/checkout@v2
49-
50-
# Switch to ubi8 rootfs
51-
- name: Switch to ubi8 rootfs
52-
run: |
53-
echo -n "mendix/rootfs:ubi8" > rootfs.version
54-
echo -n "ubi8" > docker-buildpack.version
19+
- uses: actions/checkout@v3
5520

5621
# Run the integration test script
5722
- name: Run integration tests
58-
run: sh ./.integrationtest.sh
23+
run: sh tests/integrationtest.sh

.integrationtest.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

Dockerfile

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#
44
# Author: Mendix Digital Ecosystems, [email protected]
55
# Version: 2.1.0
6-
ARG ROOTFS_IMAGE=mendix/rootfs:ubi8
7-
ARG BUILDER_ROOTFS_IMAGE=mendix/rootfs:bionic
6+
ARG ROOTFS_IMAGE=mendix-rootfs:app
7+
ARG BUILDER_ROOTFS_IMAGE=mendix-rootfs:builder
88

99
# Build stage
1010
FROM ${BUILDER_ROOTFS_IMAGE} AS builder
@@ -13,7 +13,7 @@ FROM ${BUILDER_ROOTFS_IMAGE} AS builder
1313
ARG BUILD_PATH=project
1414
ARG DD_API_KEY
1515
# CF buildpack version
16-
ARG CF_BUILDPACK=v4.30.14
16+
ARG CF_BUILDPACK=v4.30.17
1717
# CF buildpack download URL
1818
ARG CF_BUILDPACK_URL=https://github.com/mendix/cf-mendix-buildpack/releases/download/${CF_BUILDPACK}/cf-mendix-buildpack.zip
1919

@@ -36,6 +36,7 @@ ARG USER_UID=1001
3636
# 6. Update permissions of /opt/mendix so that the app can run as a non-root user
3737
RUN mkdir -p /opt/mendix/buildpack /opt/mendix/build &&\
3838
ln -s /root /home/vcap &&\
39+
mkdir -p /home/vcap/.local/bin && ln -s /etc/alternatives/pip3 /home/vcap/.local/bin/pip && pip3 install --upgrade pip &&\
3940
echo "Downloading CF Buildpack from ${CF_BUILDPACK_URL}" &&\
4041
curl -fsSL ${CF_BUILDPACK_URL} -o /tmp/cf-mendix-buildpack.zip && \
4142
python3 -m zipfile -e /tmp/cf-mendix-buildpack.zip /opt/mendix/buildpack/ &&\
@@ -44,7 +45,7 @@ RUN mkdir -p /opt/mendix/buildpack /opt/mendix/build &&\
4445
chmod -R g=u /opt/mendix
4546

4647
# Copy python scripts which execute the buildpack (exporting the VCAP variables)
47-
COPY scripts/compilation scripts/git /opt/mendix/buildpack/
48+
COPY scripts/compilation.py scripts/git /opt/mendix/buildpack/
4849

4950
# Copy project model/sources
5051
COPY $BUILD_PATH /opt/mendix/build
@@ -68,10 +69,10 @@ ENV NGINX_CUSTOM_BIN_PATH=/usr/sbin/nginx
6869
# 7. Update ownership of /opt/mendix so that the app can run as a non-root user
6970
# 8. Update permissions of /opt/mendix so that the app can run as a non-root user
7071
RUN mkdir -p /tmp/buildcache /tmp/cf-deps /var/mendix/build /var/mendix/build/.local &&\
71-
chmod +rx /opt/mendix/buildpack/compilation /opt/mendix/buildpack/git /opt/mendix/buildpack/buildpack/stage.py &&\
72+
chmod +rx /opt/mendix/buildpack/compilation.py /opt/mendix/buildpack/git /opt/mendix/buildpack/buildpack/stage.py &&\
7273
cd /opt/mendix/buildpack &&\
73-
./compilation /opt/mendix/build /tmp/buildcache /tmp/cf-deps 0 &&\
74-
rm -fr /tmp/buildcache /tmp/javasdk /tmp/opt /tmp/downloads /opt/mendix/buildpack/compilation /opt/mendix/buildpack/git &&\
74+
./compilation.py /opt/mendix/build /tmp/buildcache /tmp/cf-deps 0 &&\
75+
rm -fr /tmp/buildcache /tmp/javasdk /tmp/opt /tmp/downloads /opt/mendix/buildpack/compilation.py /opt/mendix/buildpack/git &&\
7576
ln -s /opt/mendix/.java /opt/mendix/build &&\
7677
chown -R ${USER_UID}:0 /opt/mendix /var/mendix &&\
7778
chmod -R g=u /opt/mendix /var/mendix
@@ -80,9 +81,6 @@ FROM ${ROOTFS_IMAGE}
8081
LABEL Author="Mendix Digital Ecosystems"
8182
LABEL maintainer="[email protected]"
8283

83-
# Uninstall build-time dependencies to remove potentially vulnerable libraries
84-
ARG UNINSTALL_BUILD_DEPENDENCIES=true
85-
8684
# Set the user ID
8785
ARG USER_UID=1001
8886
# Set the home path
@@ -92,17 +90,11 @@ ENV HOME=/opt/mendix/build
9290
RUN chmod g=u /etc/passwd &&\
9391
chown ${USER_UID}:0 /etc/passwd
9492

95-
# Uninstall Ubuntu packages which are only required during build time
96-
RUN if [ "$UNINSTALL_BUILD_DEPENDENCIES" = "true" ] && grep -q ubuntu /etc/os-release ; then\
97-
DEBIAN_FRONTEND=noninteractive apt-mark manual libfontconfig1 && \
98-
DEBIAN_FRONTEND=noninteractive apt-get remove --purge --auto-remove -q -y wget curl libgdiplus ; \
99-
fi
100-
10193
# Add the buildpack modules
10294
ENV PYTHONPATH "/opt/mendix/buildpack/lib/:/opt/mendix/buildpack/:/opt/mendix/buildpack/lib/python3.6/site-packages/"
10395

10496
# Copy start scripts
105-
COPY scripts/startup scripts/vcap_application.json /opt/mendix/build/
97+
COPY scripts/startup.py scripts/vcap_application.json /opt/mendix/build/
10698

10799
# Create vcap home directory for Datadog configuration
108100
RUN mkdir -p /home/vcap /opt/datadog-agent/run &&\
@@ -114,7 +106,7 @@ RUN mkdir -p /home/vcap /opt/datadog-agent/run &&\
114106
# 2. Update ownership of /opt/mendix so that the app can run as a non-root user
115107
# 3. Update permissions of /opt/mendix so that the app can run as a non-root user
116108
# 4. Ensure that running Java 8 as root will still be able to load offline licenses
117-
RUN chmod +rx /opt/mendix/build/startup &&\
109+
RUN chmod +rx /opt/mendix/build/startup.py &&\
118110
chown -R ${USER_UID}:0 /opt/mendix &&\
119111
chmod -R g=u /opt/mendix &&\
120112
ln -s /opt/mendix/.java /root
@@ -139,4 +131,4 @@ WORKDIR /opt/mendix/build
139131
ENV PORT 8080
140132
EXPOSE $PORT
141133

142-
ENTRYPOINT ["/opt/mendix/build/startup","/opt/mendix/buildpack/buildpack/start.py"]
134+
ENTRYPOINT ["/opt/mendix/build/startup.py"]

Dockerfile.rootfs.bionic

Lines changed: 0 additions & 27 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
![Test status](https://github.com/mendix/docker-mendix-buildpack/workflows/Test/badge.svg)
44

5-
The Mendix Buildpack for Docker (aka docker-mendix-buildpack) is an example project you can use to build and run your Mendix Application in a [Docker](https://www.docker.com/) container.
5+
The Mendix Buildpack for Docker (aka docker-mendix-buildpack) is an **example project** you can use to build and run your Mendix Application in a [Docker](https://www.docker.com/) container.
6+
7+
**⚠️ Warning** If your pipeline is based on Docker Buildpack V4 or an earlier version, see the [upgrading from Docker Buildpack v4](upgrading-from-v4.md) document. To use Docker Buildpack v5, some changes will be required in your build process.
8+
9+
For a Kubernetes native solution to run Mendix apps, see [Mendix for Private Cloud](https://www.mendix.com/evaluation-guide/app-lifecycle/mendix-for-private-cloud/).
610

711
## Try a sample mendix application
812

@@ -13,13 +17,17 @@ Open a terminal and run the following code:
1317
```
1418
git clone --branch <TAG> --config core.autocrlf=false https://github.com/mendix/docker-mendix-buildpack
1519
cd docker-mendix-buildpack
16-
make get-sample
17-
make build-image
18-
make run-container
20+
tests/integrationtest.sh
1921
```
2022

2123
You can now open your browser [http://localhost:8080]([http://localhost:8080])
2224

25+
### Scanning for vulnerabilities
26+
27+
If you would like to run a vulnerability scanner (to get a baseline security score), please use the latest, LTS or MTS version of Mendix.
28+
29+
Security patches are only available in the latest version of Mendix, and running a security scan on an outdated version might show CVEs that are already patched in the latest version.
30+
2331
## Uses cases scenarios:
2432

2533
This project is a goto reference for the following scenarios :
@@ -31,35 +39,64 @@ This project is a goto reference for the following scenarios :
3139

3240
### Requirements
3341

34-
* Docker 17.05 (Installation [here](https://docs.docker.com/engine/installation/))
42+
* Docker 20.10 (Installation [here](https://docs.docker.com/engine/installation/))
3543
* Earlier Docker versions are no longer compatible because they don't support multistage builds.
36-
To use Docker versions below 17.05, download an earlier Mendix Docker Buildpack release, such as [v2.3.2](https://github.com/mendix/docker-mendix-buildpack/releases/tag/v2.3.2)
37-
* For preparing, a local installation of wget (for macOS)
44+
To use Docker versions below 20.10, download an earlier Mendix Docker Buildpack release, such as [v2.3.2](https://github.com/mendix/docker-mendix-buildpack/releases/tag/v2.3.2)
45+
* For preparing, a local installation of `curl`
3846
* For local testing, make sure you can run the [docker-compose command](https://docs.docker.com/compose/install/)
47+
* A Mendix app based on Mendix 7 or a later version
3948

4049
## Usage
4150

42-
### Compilation
51+
### Preparation: rootfs
52+
53+
To save build time, the build pack needs a prebuilt rootfs containing the base OS and additional packages.
54+
This rootfs is based on [Red Hat Universal Base Image 8 minimal](https://developers.redhat.com/articles/ubi-faq) image.
55+
56+
To build the rootfs, run the following commands
57+
58+
```shell
59+
docker build -t <builder-root-fs-image-tag> -f rootfs-builder.dockerfile .
60+
docker build -t <app-root-fs-image-tag> -f rootfs-app.dockerfile .
61+
```
62+
63+
The `builder` image contains packages required to build an app; the `app` image contains a reduced package set, containing only packages required to run a Mendix app.
64+
65+
For example:
66+
67+
```shell
68+
docker build -t mendix-rootfs:app -f rootfs-app.dockerfile .
69+
docker build -t mendix-rootfs:builder -f rootfs-builder.dockerfile .
70+
```
71+
72+
This command needs to be done at least once on the builder OS.
73+
74+
Building images on a licensed RHEL host will enable access to additional packages and Red Hat support.
75+
76+
To reuse the rootfs image, push it to a private repository:
77+
78+
```shell
79+
docker push <builder-root-fs-image-tag>
80+
docker push <app-root-fs-image-tag>
81+
```
82+
83+
### Compile an app
4384

4485
Before running the container, it is necessary to build the image with your application. This buildpack contains Dockerfile with a script that will compile your application using [cf-mendix-buildpack](https://github.com/mendix/cf-mendix-buildpack/).
4586

4687
```
47-
docker build
88+
docker build \
4889
--build-arg BUILD_PATH=<mendix-project-location> \
49-
--build-arg ROOTFS_IMAGE=<root-fs-image-tag> \
50-
--build-arg BUILDER_ROOTFS_IMAGE=<root-fs-image-tag> \
51-
--build-arg CF_BUILDPACK=<cf-buildpack-version> \
5290
--tag mendix/mendix-buildpack:v1.2 .
5391
```
5492

5593
For build you can provide next arguments:
5694

5795
- **BUILD_PATH** indicates where the application model is located. It is a root directory of an unzipped .MDA or .MPK file. In the latter case, this is the directory where your .MPR file is located. Must be within [build context](https://docs.docker.com/engine/reference/commandline/build/#extended-description). Defaults to `./project`.
58-
- **ROOTFS_IMAGE** is a type of rootfs image. Defaults to `mendix/rootfs:ubi8` (Red Hat Universal Base Image 8). To use Ubuntu 18.04, change this to `mendix/rootfs:bionic`. It's also possible to use a custom rootfs image as described in [Advanced feature: full-build](#advanced-feature-full-build).
59-
- **BUILDER_ROOTFS_IMAGE** is a type of rootfs image used for downloading the Mendix app dependencies and compiling the Mendix app from source. Defaults to `mendix/rootfs:bionic`. It's also possible to use a custom rootfs image as described in [Advanced feature: full-build](#advanced-feature-full-build).
60-
- **CF_BUILDPACK** is a version of CloudFoundry buildpack. Defaults to `v4.30.14`. For stable pipelines, it's recommended to use a fixed version from **v4.30.14** and later. CloudFoundry buildpack versions below **v4.30.14** are not supported.
96+
- **ROOTFS_IMAGE** is a type of rootfs image. Defaults to `mendix-rootfs:app` (a locally prebuilt image).
97+
- **BUILDER_ROOTFS_IMAGE** is a type of rootfs image used for downloading the Mendix app dependencies and compiling the Mendix app from source. Defaults to `mendix-rootfs:builder` (a locally prebuilt image).
98+
- **CF_BUILDPACK** is a version of CloudFoundry buildpack. Defaults to `v4.30.17`. For stable pipelines, it's recommended to use a fixed version from **v4.30.17** and later. CloudFoundry buildpack versions below **v4.30.17** are not supported.
6199
- **EXCLUDE_LOGFILTER** will exclude the `mendix-logfilter` binary from the resulting Docker image if set to `true`. Defaults to `true`. Excluding `mendix-logfilter` will reduce the image size and remove a component that's not commonly used; the `LOG_RATELIMIT` environment variable option will be disabled.
62-
- **UNINSTALL_BUILD_DEPENDENCIES** will uninstall packages which are not needed to launch an app, and are only used during the build phase. Defaults to `true`. This option will remove several libraries which are known to have unpatched CVE vulnerabilities.
63100
- **CF_BUILDPACK_URL** specifies the URL where the CF buildpack should be downloaded from (for example, a local mirror). Defaults to `https://github.com/mendix/cf-mendix-buildpack/releases/download/${CF_BUILDPACK}/cf-mendix-buildpack.zip`. Specifying **CF_BUILDPACK_URL** will override the version from **CF_BUILDPACK**.
64101
- **BLOBSTORE** can be used to specify an alternative buildpack resource server (instead of the default Mendix CDN). For more information, see the [CF Buildpack offline settings](https://github.com/mendix/cf-mendix-buildpack#offline-buildpack-settings).
65102
- **BUILDPACK_XTRACE** can be used to enable CF Buildpack [debug logging](https://github.com/mendix/cf-mendix-buildpack#logging-and-debugging). Set this variable to `true` to enable debug logging.
@@ -190,7 +227,7 @@ environment:
190227

191228
### Configuring Custom Runtime Settings
192229

193-
To configure any of the advanced [Custom Runtime Settings](https://world.mendix.com/display/refguide6/Custom+Settings) you can use setting name prefixed with `MXRUNTIME_` as an environment variable.
230+
To configure any of the advanced [Custom Runtime Settings](https://docs.mendix.com/refguide/custom-settings/) you can use setting name prefixed with `MXRUNTIME_` as an environment variable.
194231

195232
For example, to configure the ConnectionPoolingMinIdle setting to value 10, you can set the following environment variable:
196233

@@ -290,25 +327,6 @@ In case your environment does not support multi-line environment variables, a Ba
290327

291328
This string should be set into the CERTIFICATE_AUTHORITIES_BASE64 environment variable.
292329

293-
### Advanced feature: full-build
294-
295-
To save build time, the build pack will normally use a pre-built rootfs from Docker Hub. This rootfs is prepared nightly by Mendix using [this](https://github.com/mendix/docker-mendix-buildpack/blob/master/Dockerfile.rootfs.bionic) Dockerfile. If you want to build the root-fs yourself you can use the following script:
296-
297-
```
298-
docker build --build-arg BUILD_PATH=<mendix-project-location> \
299-
-t <root-fs-image-tag> -f Dockerfile.rootfs.bionic .
300-
```
301-
302-
After that you can build the target image with the next command:
303-
304-
```
305-
docker build
306-
--build-arg BUILD_PATH=<mendix-project-location> \
307-
--build-arg ROOTFS_IMAGE=<root-fs-image-tag> \
308-
--build-arg BUILDER_ROOTFS_IMAGE=<builder-root-fs-image-tag> \
309-
```
310-
-t mendix/mendix-buildpack:v1.2 .
311-
312330

313331
### Industrial Edge Configuration File support
314332

@@ -349,11 +367,11 @@ Contributions are welcomed:
349367

350368
This was built with the following:
351369

352-
* Docker version 18.06.3
370+
* Docker version 20.10
353371

354372
### Versioning
355373

356-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/mendix/IBM-Watson-Connector-Kit/tags).
374+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/mendix/docker-mendix-buildpack/tags).
357375

358376
## License
359377

cf-buildpack.version

Lines changed: 0 additions & 1 deletion
This file was deleted.

docker-buildpack.version

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)