Skip to content

Commit

Permalink
Merge pull request #177 from mendix/DES-5253_fix-builds
Browse files Browse the repository at this point in the history
DES-5253 Fix builds
  • Loading branch information
zlogic authored Jul 26, 2023
2 parents 3a91cde + 48ac3d5 commit 38f09bd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

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.

**⚠️ Warning** At this time, Docker Buildpack doesn't support building Mendix 10 MPK files. To deploy a Mendix 10 app with Docker Buildpack, you will need to build the MDA file first (using Studio Pro 10 or [MxBuild](https://docs.mendix.com/refguide/mxbuild/)), and deploy the MDA file using Docker Buildpack.

**⚠️ 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.

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/).
Expand Down
2 changes: 1 addition & 1 deletion rootfs-app.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENV LC_ALL C.UTF-8
# install dependencies & remove package lists
RUN microdnf update -y && \
microdnf module enable nginx:1.20 -y && \
microdnf install -y glibc-langpack-en python311 openssl nginx nginx-mod-stream java-11-openjdk-headless fontconfig && \
microdnf install -y glibc-langpack-en python311 openssl nginx nginx-mod-stream java-11-openjdk-headless tzdata-java fontconfig && \
microdnf clean all && rm -rf /var/cache/yum

# Set nginx permissions
Expand Down
6 changes: 3 additions & 3 deletions rootfs-builder.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# CF buildpack version
ARG CF_BUILDPACK=v5.0.0
ARG CF_BUILDPACK=v5.0.4
# CF buildpack download URL
ARG CF_BUILDPACK_URL=https://github.com/mendix/cf-mendix-buildpack/releases/download/${CF_BUILDPACK}/cf-mendix-buildpack.zip

Expand All @@ -33,7 +33,7 @@ RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.
microdnf clean all && rm -rf /var/cache/yum

# Install RHEL alternatives to CF Buildpack dependencies
RUN microdnf install -y java-11-openjdk-headless java-11-openjdk-devel mono-core-5.20.1.34 libgdiplus0 libicu && \
RUN microdnf install -y java-11-openjdk-headless java-11-openjdk-devel tzdata-java mono-core-5.20.1.34 libgdiplus0 libicu && \
microdnf clean all && rm -rf /var/cache/yum

# Set nginx permissions
Expand Down Expand Up @@ -69,7 +69,7 @@ RUN mkdir -p /opt/mendix/buildpack /opt/mendix/build &&\
chmod -R g=u /opt/mendix

# Copy python scripts which execute the buildpack (exporting the VCAP variables)
COPY scripts/compilation.py scripts/git /opt/mendix/buildpack/
COPY scripts/compilation.py scripts/git scripts/mono-adapter /opt/mendix/buildpack/

# Install the buildpack Python dependencies
RUN PYTHON_BUILD_RPMS="python3.11-pip python3.11-devel libffi-devel gcc" && \
Expand Down
11 changes: 9 additions & 2 deletions scripts/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@ def export_vcap_services():
def replace_cf_dependencies():
logging.debug("Ensuring CF Buildpack dependencies are available")

mx_version = runtime.get_runtime_version("/opt/mendix/build")
logging.debug("Detected Mendix version {0}".format(mx_version))

# Only mono 5 is supported by Docker Buildpack
mono_dependency = get_dependency("mono.5-jammy", "/opt/mendix/buildpack")
logging.debug("Creating symlink for mono {0}".format(mono_dependency['artifact']))

util.mkdir_p("/tmp/buildcache/bust")
mono_cache_artifact = f"/tmp/buildcache/bust/mono-{mono_dependency['version']}-mx-ubuntu-jammy.tar.gz"
with tarfile.open(mono_cache_artifact, "w:gz") as tar:
# Symlinks to use mono from host OS
symlinks = {'mono/bin':'/usr/bin', 'mono/lib': '/usr/lib64', 'mono/etc': '/etc'}
if mx_version.major >= 10:
# Mono is not needed for Mendix 10, use the bash adapter script
symlinks = {'mono/bin/mono':'/opt/mendix/buildpack/mono-adapter', 'mono/lib': '/usr/lib64'}
else:
# Symlinks to use mono from host OS
symlinks = {'mono/bin':'/usr/bin', 'mono/lib': '/usr/lib64', 'mono/etc': '/etc'}
for source, destination in symlinks.items():
symlink = tarfile.TarInfo(source)
symlink.type = tarfile.SYMTYPE
Expand Down
27 changes: 27 additions & 0 deletions scripts/mono-adapter
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# This script works as a drop-in replacement for mono and allows using non-mono mxbuild in CF Buildpack.
# It's a temporary workaround until https://github.com/mendix/cf-mendix-buildpack/pull/661 is available in CF Buildpack v5.

MONO_ARGS=()
# Rewrite the command to exclude mono and its args, only keep mxbuild
while [[ $# -gt 0 ]]; do
case $1 in
*mxbuild.exe)
# Remove .exe from mxbuild executable name
MONO_ARGS=(${1%.*})
shift
;;
*)
# Keep all args after mxbuild
if [ -n "$MONO_ARGS" ]; then
MONO_ARGS+=("$1")
fi
shift
;;
esac
done

echo "Launching MxBuild through mono adapter..."

exec "${MONO_ARGS[@]}"

0 comments on commit 38f09bd

Please sign in to comment.