I’m a data scientist. Deploying is not part of my core skills, but something I need to be able to do when working on hobby projects. I recently embraced DigitalOcean to deploy my Django (Python) Project and want to elaborate on a problem I ran into.
The error that appeared in the log files when building and deploying my application to the DigitalOcean App Platform was the following:
PermissionError: [Errno 1] Operation not permitted
It was followed the worker exiting and a display of the Python traceback logs. Judging from the error message, it’s got something to do with permission. Given the fact that the traceback ends with os.fchmod(…), there’s no doubt about it.
Apparently, gunicorn’s worker heartbeat temporary file has no access to the default directory on DigitalOcean. Solving it is extremely easy and is actually covered in the extensive deployment documentation that DigitalOcean provides.
In the app dashboard in DigitalOcean’s app platform, go to the components tab and edit the build and run command.
Edit the run command and change it to:
gunicorn --worker-tmp-dir /dev/shm <YOUR_DJANGO_PROJECT_NAME>.wsgi
Replace YOUR_DJANGO_PROJECT_NAME with the name of your Django project. Most likely, this is the name of the root folder of your project.
Congratulations, you can now deploy your app properly.