I'm trying to test a django app in a docker image. I have followed the tutorial until the it starts the django project. When I run, docker-compose run web django-admin startproject composeexample . I get
Error response from daemon: OCI runtime create failed:
container_linux.go:380: starting container process caused: exec:
"django-admin": executable file not found in $PATH: unknown
ERROR: 1
It's weird because I can run django-admin createproject ... seperately. Any thoughts?
I have added the ..\python39\scripts in the path. Also I have python 3.9.10 from the windows store.
I'm on Windows 10.
I created and git initialized a simple flask app that contains:
.git
.platform/hooks/postdeploy/01_runsomething.sh (contains "#!/bin/sh python print_helloworld.py")
.ebignore (ignores "venv")
venv
application.py
print_helloworld.py (independent Python file, contains "print('hello world')")
requirements.txt
Flask app runs fine on my personal computer.
I'm trying to upload it on Elastic Beanstalk and make it run "print_helloworld.py" periodically after deployment.
But, the flask app gets error during deployment:
2021/11/11 19:56:13.160939 [INFO] Executing instruction: RunAppDeployPostDeployHooks
2021/11/11 19:56:13.160959 [INFO] Executing platform hooks in .platform/hooks/postdeploy/
2021/11/11 19:56:13.161018 [INFO] Following platform hooks will be executed in order: [01_runsomething.sh]
2021/11/11 19:56:13.161027 [INFO] Running platform hook: .platform/hooks/postdeploy/01_runsomething.sh
2021/11/11 19:56:13.162276 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPostDeployHooks]. Stop running the command. Error: Command .platform/hooks/postdeploy/01_runsomething.sh failed with error fork/exec .platform/hooks/postdeploy/01_runsomething.sh: permission denied
What can I do to solve this permission error?
I made 01_runsomething.sh executable by using Ubuntu (downloaded from Microsoft Store) on Windows 10 and used:
chmod +x .platform/hooks/postdeploy/01_runsomething.sh
git update-index .platform/hooks/postdeploy/01_runsomething.sh
Then, I checked the permission on Ubuntu (ls -l .platform/hooks/postdeploy/01_runsomething.sh), and it looks like this:
-rwxrwxrwx 1 root root 279 Nov 10 20:33 .platform/hooks/postdeploy/01_runsomething.sh
But, the flask app still returns same error on Elastic Beanstalk. Not sure if that solution works.
What can I do to solve this permission error?
I'm deploying a flask (flask-restplus) REST API to an AWS Elastic Beanstalk instance, and I'm running into a weird failure mode.
One of my API endpoints has a dependency on OpenCV, which requires some dependencies as outlined at: ImportError: libGL.so.1: cannot open shared object file: No such file or directory while importing OCC. Per the answers there, I created an .ebextensions directory and created two files, one to install the libGL packages, which looks like this:
packages:
yum:
mesa-libGL : []
mesa-libGL-devel : []
I saved that file as packages.config, if that matters.
The second file in .ebextensions downloads and installs zlib:
commands:
00_download_zlib:
command: |
wget https://github.com/madler/zlib/archive/v1.2.9.tar.gz
tar xzvf v1.2.9.tar.gz
cd zlib-1.2.9
./configure
make
make install
ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so
ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so.1
I saved that file as zlib.config.
When I first ran eb deploy, everything worked great. Deployment was successful, my API responded to requests, and the code that depended on OpenCV worked. So far so good.
However, on subsequent deployments, I've gotten the following errors:
2020-11-18 23:47:44 ERROR Instance deployment failed. For details, see 'eb-engine.log'.
2020-11-18 23:47:45 ERROR [Instance: i-XXXXXXXXXXXXX] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error..
2020-11-18 23:47:45 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-11-18 23:47:45 ERROR Unsuccessful command execution on instance id(s) 'i-XXXXXXXXXXXXX'. Aborting the operation.
2020-11-18 23:47:46 ERROR Failed to deploy application.
I went in and pulled down the logs from the instance, first looking at eb-engine.log. The only error there is:
2020/11/18 23:47:44.131837 [ERROR] An error occurred during execution of command [app-deploy] - [PreBuildEbExtension]. Stop running the command. Error: EbExtension build failed. Please refer to /var/log/cfn-init.log for more details.
However, looking at cfn-init.log just indicates that everything succeeded:
2020-11-18 23:47:34,297 [INFO] -----------------------Starting build-----------------------
2020-11-18 23:47:34,306 [INFO] Running configSets: Infra-EmbeddedPreBuild
2020-11-18 23:47:34,309 [INFO] Running configSet Infra-EmbeddedPreBuild
2020-11-18 23:47:34,313 [INFO] Running config prebuild_0_newapi
2020-11-18 23:47:36,512 [INFO] Running config prebuild_1_newapi
2020-11-18 23:47:44,106 [INFO] Command 00_download_zlib succeeded
2020-11-18 23:47:44,108 [INFO] ConfigSets completed
2020-11-18 23:47:44,108 [INFO] -----------------------Build complete-----------------------
I then tried removing the entire .ebextensions directory and re-deploying, and the deployment succeeded. Then I tried adding back the .ebextensions directory and adding the files one at a time, and discovered that the deployment worked fine when I added packages.config, but failed again when I added zlib.config.
My question boils down to: why is this happening, and is there anything I can do to resolve it? My understanding is that I need both of these files deployed to my instance in case I migrate to a different enviroment, or AutoScaling migrates my instance, etc.
The only thing I can think of is that the instance doesn't like the fact that I keep re-installing zlib, but the cfn-init-cmd.log indicates that all the commands in zlib.config are succeeding, as does cfn-init.log. So why is eb-engine.log reporting an error? Is it telling me to look in the wrong place for logs that may be relevant? I've looked in every log file and I don't see anything else indicating any issues.
I did find one tangentially-related possible solution relating to Immutable Environment Updates, which looks like it may work but feels like a bit of unnecessary work. At the very least I'd like to understand why I need to make that change and why Elastic Beanstalk isn't playing nicer with my .ebextensions.
Just in case anyone runs across this in the future, I wanted to share the solution. I was never able to determine why the zlib install process was failing after the first deployment on an instance, so I ended up using the Immutable Environment Updates settings I linked in my original question.
Deployments take a bit longer to process as the deployment creates an autoscaling group and a new instance on each deployment, but my deployments just work every time now.
I am following along with this tutorial for running a Flask server using Docker. I am working on a Windows machine so I am using Docker Toolbox.
Once I enter the command to create the database table:
docker-compose run web /usr/local/bin/python create_db.py
I get the following error:
Error response from daemon: OCI runtime create failed:
container_linux.go:346: starting container process caused "exec:
\"C:/Program Files/Git/usr/local/bin/python\": stat C:/Program
Files/Git/usr/local/bin/python: no such file or directory": unknown
I am not sure why I am getting this error, any suggestions on how to fix this error would be greatly appreciated. Thank you.
The command fails because windows tries to parse the path, this can be circumvented by quoting the path:
docker-compose run web python create_db.py
If the above fails a double dash can be used:
docker-compose run web -- "/usr/local/bin/python create_db.py"
I had to change the current directory, and then to execute the script :
docker-compose run web bash -c "cd /usr/local/bin/; python create_db.py"
I have a Django 1.11/Python 3.5 app that I built and want to run on Heroku locally. It's a simple SPA using the Heroku Django template provided on GitHub (https://github.com/heroku/heroku-django-template). I followed a Heroku tutorial (https://devcenter.heroku.com/articles/deploying-python#how-to-keep-build-artifacts-out-of-git), but I cannot seem to run the app locally using the following command:
heroku local web
Running this produces the following error:
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open '.env'
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:491:33)
at loadEnvsFile (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/lib/envs.js:133:15)
at Array.map (native)
at loadEnvs (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/lib/envs.js:148:30)
at Command.<anonymous> (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/nf.js:72:16)
at Command.listener (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/commander/index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:194:7)
at Command.parseArgs (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/commander/index.js:615:12)
My .env file looks like this:
WEB_CONCURRENCY=3
SECRET_APP_KEY="xxxxxxxxxxxxxxxxxxxx"
I ran chmod 777 on .env but I get the same error.
When I run the following command:
heroku local
I get the following error:
[WARN] EACCES: permission denied, open 'Procfile'
[FAIL] No Procfile and no package.json file found in Current Directory - See run.js --help
▸ Cannot convert undefined or null to object
My Procfile looks like this:
web: gunicorn personal_website.wsgi
Now I cannot understand why when running "heroku local web" I get the previously mentioned error, especially after giving it the necessary permissions.
Also, others have had the same error when running "heroku local", but the answer is to "make sure the formatting of your Procfile is correct." Well mine is correct and have tried many variations to it.
I have seen others with this issue on SO and some have been resolved, unfortunately for me none of them worked.
What could I possibly be doing wrong here?