B4J Question PyBridge - What about the python's side communicating process position in a secured Docker Container?

hatzisn

Expert
Licensed User
Longtime User
I was reading the basics of PyBridge (here) and I would like to ask a single question which seems to be obvious but if you are not familiar with python yet, nothing is too obvious. It says that it starts a process that communicates with B4J. To my non expert eyes this seems to me that it creates a .py file and runs it with the python runtime. Right or wrong? If it is right then where is this file saved? Can I choose the folder to save this file? This is because if you create a docker container that utilizes python for a web app, then for security reasons it is suggested to run the app with a low privileges user which has to have (as a part of all) rx access to the folders (and the files in them recursively) it will execute the files and rwx to the folders he is supposed to write. All the other container must be immutable and inaccessible to him. So can I put the communicating .py script in a selected directory which will be rwx for the non privileged user and start it with the full path? And another thing is obviously that I have to make also the python3 executable rx for all, right? And this goes on to the libraries that it will use, right? Well, after all it was not just a single question.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
A python module is copied to PyOptions.PyBridgePath. The default value is:
B4X:
opt.PyBridgePath = File.Combine(File.DirData("pybridge"), $"b4x_bridge_${Utils.PythonBridgeCodeVersion}.zip"$)

You can change it if needed. Note that if the file already exists then it will not be overwritten.

You will see a message in the logs when the module is copied:
B4X:
If File.Exists(Options.PyBridgePath, "") = False Or mOptions.ForceCopyBridgeSrc Then
            File.Copy(File.DirAssets, "b4x_bridge.zip", Options.PyBridgePath, "")
            Utils.PyLog(Utils.B4JPrefix, mOptions.B4JColor, "Python package copied to: " & Options.PyBridgePath)
        End If
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Upvote 0
Top