mendix / docker-mendix-buildpack

Build and Run Mendix in Docker
https://www.mendix.com
Apache License 2.0
82 stars 112 forks source link

PermissionError: [Errno 13] Permission denied: '/tmp/opt/mono-5.20.1.27/bin/mono' #183

Open franksoong opened 11 months ago

franksoong commented 11 months ago

HI Team, when i run latest version(branch) buildpack for you Mendix10 project, it throws below error, please he help:

PermissionError: [Errno 13] Permission denied: '/tmp/opt/mono-5.20.1.27/bin/mono'

the complete outputs:

[7pcqtf@shli6073 docker-mendix-buildpack]$ sudo docker build --build-arg BUILD_PATH=build .
[sudo] password for 7pcqtf:
Sending build context to Docker daemon  431.1MB
Step 1/28 : ARG ROOTFS_IMAGE=mendix-rootfs:app
Step 2/28 : ARG BUILDER_ROOTFS_IMAGE=mendix-rootfs:builder
Step 3/28 : FROM ${BUILDER_ROOTFS_IMAGE} AS builder
 ---> 88c692e31745
Step 4/28 : ARG BUILD_PATH=project
 ---> Running in b8e5375aa675
Removing intermediate container b8e5375aa675
 ---> 5332dd797470
Step 5/28 : ARG DD_API_KEY
 ---> Running in 1896c2b277fd
Removing intermediate container 1896c2b277fd
 ---> 066a3c8c173c
Step 6/28 : ARG EXCLUDE_LOGFILTER=true
 ---> Running in 14d687ac7c66
Removing intermediate container 14d687ac7c66
 ---> 966f761ac08b
Step 7/28 : ARG BLOBSTORE
 ---> Running in 480307dcb088
Removing intermediate container 480307dcb088
 ---> 8e122b8eaf42
Step 8/28 : ARG BUILDPACK_XTRACE
 ---> Running in 97004663c3d9
Removing intermediate container 97004663c3d9
 ---> 33091e620280
Step 9/28 : COPY $BUILD_PATH /opt/mendix/build
 ---> 98fbb4fc324b
Step 10/28 : ENV NGINX_CUSTOM_BIN_PATH=/usr/sbin/nginx
 ---> Running in ee2c3855cd10
Removing intermediate container ee2c3855cd10
 ---> 76cb48b88bcd
Step 11/28 : RUN mkdir -p /tmp/buildcache /tmp/cf-deps /var/mendix/build /var/mendix/build/.local &&    chmod +rx /opt/mendix/buildpack/compilation.py /opt/mendix/buildpack/git /opt/mendix/buildpack/buildpack/stage.py &&    cd /opt/mendix/buildpack &&    ./compilation.py /opt/mendix/build /tmp/buildcache /tmp/cf-deps 0 &&    rm -fr /tmp/buildcache /tmp/javasdk /tmp/opt /tmp/downloads /opt/mendix/buildpack/compilation.py /opt/mendix/buildpack/git &&    ln -s /opt/mendix/.java /opt/mendix/build &&    chown -R ${USER_UID}:0 /opt/mendix /var/mendix &&    chmod -R g=u /opt/mendix /var/mendix
 ---> Running in 4bf77bf159ca
INFO: Mendix project compilation phase...
INFO: Preflight check on Mendix version [10.0.0.9976] and stack [cflinuxfs4]...
INFO: Mendix [10.0] is not maintained. Please use a medium- or long-term supported Mendix version to easily receive fixes (https://docs.mendix.com/releasenotes/studio-pro/lts-mts).
INFO: Preflight check completed
INFO: Building from source...
INFO: Selecting Mono Runtime: 5
Traceback (most recent call last):
  File "/opt/mendix/buildpack/./compilation.py", line 102, in <module>
    compilation_globals = call_buildpack_compilation()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mendix/buildpack/./compilation.py", line 87, in call_buildpack_compilation
    return runpy.run_module("buildpack.stage", run_name="__main__")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 229, in run_module
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/mendix/buildpack/buildpack/stage.py", line 178, in <module>
    mxbuild.build_from_source(
  File "/opt/mendix/buildpack/buildpack/core/mxbuild.py", line 67, in build_from_source
    subprocess.check_call(args, env=mono_env)
  File "/usr/lib64/python3.11/subprocess.py", line 408, in check_call
    retcode = call(*popenargs, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 389, in call
    with Popen(*popenargs, **kwargs) as p:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/tmp/opt/mono-5.20.1.27/bin/mono'
The command '/bin/sh -c mkdir -p /tmp/buildcache /tmp/cf-deps /var/mendix/build /var/mendix/build/.local &&    chmod +rx /opt/mendix/buildpack/compilation.py /opt/mendix/buildpack/git /opt/mendix/buildpack/buildpack/stage.py &&    cd /opt/mendix/buildpack &&    ./compilation.py /opt/mendix/build /tmp/buildcache /tmp/cf-deps 0 &&    rm -fr /tmp/buildcache /tmp/javasdk /tmp/opt /tmp/downloads /opt/mendix/buildpack/compilation.py /opt/mendix/buildpack/git &&    ln -s /opt/mendix/.java /opt/mendix/build &&    chown -R ${USER_UID}:0 /opt/mendix /var/mendix &&    chmod -R g=u /opt/mendix /var/mendix' returned a non-zero code: 1
franksoong commented 11 months ago

i am using https://github.com/mendix/docker-mendix-buildpack/tree/latest

jmeeske commented 7 months ago

I ran in the same issue with Azure Devops Ubuntu hosted agents. Also on a local ubuntu 22.04 installation. But when I tried Debian. There the issue does not occur on the latest branch.

So I think this has to do with a difference in a way the linux distro's handle Docker & premissions(??)

Eventually I am using a self hosted agent atm and configured it with Docker, git and unzip. I first run the integration.sh script, then start to build the image. That works

xiwenc commented 7 months ago

@jmeeske interesting... thanks for sharing the finding!

If that's the case then i suspect there's potentially an issue with kernel compatibility of binfmt.

https://askubuntu.com/questions/20246/running-a-mono-program-without-typing-in-mono-foo-exe

A workaround would be to call mono directly.

But looking at the error message, doesn't look like mxbuild is called directly. So binfmt should not be involved.

Perhaps the mono 5.20 shipped is not compatible with Ubuntu.

Other hypothesis: /tmp is mounted with noexec flag. That could explain the no permission error

https://www.howtouselinux.com/post/resolving-the-permission-denied-error-in-linux-caused-by-the-noexec-mount-option

ppoetsma commented 1 month ago

I'm running into this same issue. Using the most recent, at this point in time, Mx docker buildpack on Azure AKS. No modifications and runs fine with Mx 9.24. But with Mx 10 I get exactly this issue. There are no Mx 10 users with this buildpack or is it very obvious to fix?

Updates:

xiwenc commented 1 month ago

@ppoetsma we use this buildpack at a customer I know for sure are on mendix 10.x . However last week another customer reported similar issue as above for mendix 10.12. We noticed the same problem with some of our test projects.

Are you getting the following error:

2024-08-08T11:23:11.3525199Z #16 24.83 Cannot open assembly '/opt/mendix/build/.local/mxbuild/modeler/mxbuild.exe': No such file or directory.
2024-08-08T11:23:11.5154618Z #16 24.84 ERROR: Could not read MxBuild error file
2024-08-08T11:23:11.5155262Z #16 24.84 Traceback (most recent call last):
2024-08-08T11:23:11.5156043Z #16 24.84   File "/opt/mendix/buildpack/buildpack/core/mxbuild.py", line 70, in build_from_source
2024-08-08T11:23:11.5156385Z #16 24.84     subprocess.check_call(args, env=mono_env)
2024-08-08T11:23:11.5156666Z #16 24.84   File "/usr/lib64/python3.6/subprocess.py", line 311, in check_call
2024-08-08T11:23:11.5156908Z #16 24.84     raise CalledProcessError(retcode, cmd)
2024-08-08T11:23:11.5158135Z #16 24.84 subprocess.CalledProcessError: Command '['/tmp/opt/mono-5.20.1.27/bin/mono', '--config', '/tmp/opt/mono-5.20.1.27/etc/mono/config', '/opt/mendix/build/.local/mxbuild/modeler/mxbuild.exe', '--target=package', '--output=/tmp/model.mda', '--java-home=/opt/mendix/build/.local/usr/lib/jvm/Adoptium-jdk-11.0.16-Adoptium-x64', '--java-exe-path=/opt/mendix/build/.local/usr/lib/jvm/Adoptium-jdk-11.0.16-Adoptium-x64/bin/java', '--write-errors=/tmp/builderrors.json', '/opt/mendix/build/XXX.mpr']' returned non-zero exit status 2.
2024-08-08T11:23:11.5158926Z #16 24.84 

I don't have any fix yet unfortunately.

ppoetsma commented 1 month ago

@xiwenc We get the same error as OP. That is in Azure AKS. But I am able to build a Mx 10.12.1 app locally using Debian WSL on Windows 11. WSL uses Docker Desktop of Windows but I run the commands from the WSL terminal.

We use the same app in both cases. It is quite frustrating that we are not able to make it work.

ppoetsma commented 1 month ago

It seems that our problem is solved. When you perform the workflow, so clone buildback and build the rootfs's etc from Linux (Windows WSL is fine too) then it works. The first part of the workflow was done in Windows and that resulted in the error OP ran into too. We have not proven the solution yet, by doing the workflow partially in Windows again.

Update: We can reproduce the issue by having Windows in the workflow. When we replaced it with Linux then the issue was solved. Now we pull/clone the Github buildpack repo directly in an Azure DevOps repo.

xiwenc commented 1 month ago

2024-08-08T11:23:11.3525199Z #16 24.83 Cannot open assembly '/opt/mendix/build/.local/mxbuild/modeler/mxbuild.exe': No such file or directory.

This was a different issue and upgrading to docker-mendix-buildpack v5.0.5 fixes it.