'How to obfuscate Python code with buildpacks?

I am using pack cli to build docker image for my python flask app running with gunicorn.

Inside docker image, my whole code is exposed in workspace folder.

What shall i do to restrict user to access folder or obfuscate my code? I am using Google Buildpack

pack set-default-builder gcr.io/buildpacks/builder:v1


Solution 1:[1]

I'm assuming you're using the Heroku Python Buildpack (and the heroku/buildpacks:18 builder).

You can create a bin/post_compile and use it to run compileall, and then run rm **/*.py

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 codefinger