Cloudfoundry : Activate some PHP extentions in a custom buildpack - cloud-foundry

I want to enlable some PHP extentions in my custom PHP-Buildpack. But I don't know which one to edit... I tried to change the options.json in the "defaults" folder, but I get an error when I push the app via the cf command. And there is easily 20 other files named like that.
Can somebody help me to find the good one ? Thank you :)

The file has to be on the app folder, not in the buildpack folder. It has to be in a folder named ".bp-config" on the root of your app's directory.

Related

Problem with static folder IIS for Django

I have a static folder set in django to a network path
STATICFILES_DIRS = [
"//SERVER/Shared1/FOLDER_210121/",
]
and I have 2 pages that have links to this static subfolders
link1: http://server2:8044/static/folder1/COINS_LIVE_OU164/user1310200781810167.tif
link2: http://server2:8044/static/folder2/COINS_LIVE_OU164/user2310200781810167.tif
however link1 works perfectly but link 2 gives me an error as file not found
but the file does exist, and from IIS I have set a virtual directory aliased as "static" with the root folder that contains the subfolder from where I get the files.
I can navigate from the virtual directory to both files, the virutal directory was created with the defaultAppPool user.
is there something else I could check?
(if I run the manage.py runserver command and I use localhost I can download both files, the issue is when using it from the IIS).
if I print the value of static in a label the path is ok, so I'm guessing permission, but where can I be missing the configuration?
Thank you.
Adding a bit more info:
the issue affects a subfolder inside the "static" folder, 1 can enter without probelms, the other can't.
I'm getting crazy. I deleted all, created again, and the issue still occurs.
I was able to solve my particualr problem, it was fixed by putting the static handler module mapping alone with the Django FastCGI (custom) module in the website IIS

Django collectstatic keeps waiting when run through Github Action

We are facing a very weird issue. We ship a django application in a docker container through Github Actions on each push. Everything is working fine except collectstatic.
We have the following lines at the end of our CD github action:
docker exec container_name python manage.py migrate --noinput
docker exec container_name python manage.py collectstatic --noinput
migrate works perfectly fine, but collectstatic just keeps on waiting if ran through the github action. If I run the command directly on the server then it works just fine and completes with in few minutes.
Can someone please help me figuring out what could be the issue?
Thanks in advance.
Now I am far from the most experienced but I did this recently and I have some suggestions of where to look. I'm definitely not the greatest authority though.
I wasn't using docker so I can't say anything about that. From the issues, I had here are some suggestions I can recommend to try.
Take note that all of this was for a self-hosted runner. Things would be very different otherwise.
Check to make sure STATIC_ROOT and MEDIA_ROOT variables are set correctly in the settings file.
If the STATIC and MEDIA root variables are environment variables make sure you are serving the correct environment variables file like a .env file which I used.
I used django-environ to serve my environment variables. From the docs, it says to have the .env file in the same directory as the settings file. Well if you are putting the project on a production server with github actions, you won't be able to put the .env file anywhere in the project because it will get overwritten every time new code is pushed.
So to fix that you need to specify the correct .env file from somewhere else on the server. Do that by specifying ENV_PATH.
https://django-environ.readthedocs.io/en/latest/
Under the section Multiple env files
Another resource that was helpful:
https://github.com/joke2k/django-environ/issues/143
I set up my settings file like how they did there.
I put my .env file in a proj directory I made in the virtualenvironment folder for the project.
I don't know if it's a good place to put it but that's how I did it. I didn't find much great info online for this stuff. Had to figure out a lot on my own.
Make sure the user which is running the github action has permissions to read the .env file.
Also like .env file, if you have the static files being collected into the base directory of your project you might have an issue with github actions overwriting those files every time new code is pushed. If you have a media directory where the user uploads files to then that will really be an issue because those files won't get overwritten. They'll just disappear.
Now if this was an issue it shouldn't cause github actions to just get stuck on the collect static command. It would just cause files to get overwritten every time the workflow runs and the media files will disappear.
If you do change the directory of where the static and media files are located as stated before, make sure all the variables for the paths are correct in the settings file and the .env file.
You will also need to update the nginx config file for the static and media root directories if you used nginx. Not sure about how apache does this.
You can do that with this command:
sudo nano /etc/nginx/sites-available/myproject
Don't forget to restart the nginx server after doing that.
If you are writing static and media files at a different location from the base project directory on the server, also check permissions on those directories. Make sure the user running the github action has permissions to write to those directories. I suspect that might cause it to hang but it very well might just cause an error.
Check all the syntax in the github actions yml file. Make sure everything is correct and it's not hanging cause it had an incomplete command or something like that.
But yeah, that's some things I had to take a look at. Honestly, none of this might be relevant for you. All of these issues should cause an error somewhere for the most part.
I couldn't really offer many external resources for you to look deeper into this because I'm just speaking from personal experience.
Hope I could help.
Heres my github repo for the project I did: https://github.com/pkudlanov/personal-portfolio-django
I hosted it on digitalocean on a linux server using nginx and gunicorn.

How to add Procfile in pycharm for Heroku deplyment?

Trying to add a Procfile to my pycharm django project but it just asking me for the file extention. Any idea??
Go to file > new file > type in Procfile > enter > select the type: file containing setting for the editor
Give it the extension .txt, edit it and then refactor the file to be without an extension again.
To my knowledge, you first have to install the Heroku CLI.
Go to Deploy on your Heroku app page then go to "Download and install the Heroku CLI".
After downloading, restart Pycharm and it should work.
Make sure your venv is activated before you create a Procfile. You should be free to create it without an extension if the venv is activated.

django-registration-redux dont create the folder in my app

Im trying to install django-registration-redux to my app and it work but I can't see where is the folder 'registration'.
It's really extrange, it work, but I need change the templates but I cant see where they are. Somebody can explain me where is the folder?
If you are using virtualenv you can find it in
path_to_virtual_env/lib/pythonx.x/site-packages/registration
or in /usr/local/lib/pythonx.x/dist-packages/registration if you are don't using virtualenv
I had the same problem.
I solved this by cutting the folder from the lib/site-packages/registration and added the registration folder under my-project folder.
it will me something similar to this:
my-project
app
registration
Make sure that you have registration added in your INSTALLED_APPS
This suppose to work since you have your set urls.py

Target WSGI script not found or unable to stat

Target WSGI script not found or unable to stat: /opt/python/current/app/application.py
I contain my app in a file called application.py, and my application's configuration looks like this:
I also tried uploading the sample app that AWS provides, which only contains 'application.py`, and yet I still get this error.
What could be causing the error?
For me, it was this silly thing. In my mac, I compressed by right-clicking on the folder/repository and compressing it to zip. However, a zip like that extracts to open another folder within it which contains the application. As a result, EBS is unable to locate application.py.
The simple fix hence was to select all the individual files inside the folder to create the zip file for uploading (or using the EB CLI to upload).
I had a similar issue. You should put your application.py in root directory as your WSGIPath suggests, or change your WSGIPath in .elasticbeanstalk/optionsettings.yourappname-env.
For me, I had my app instance stored in a variable called app, which wasn't recognised by Elastic Beanstalk. As soon as I changed the variable to application, it started working.
# In application.py or manage.py, after initialising the app
application = app
should do the trick.
Use application instead of app or any other variable you are using.
application = Flask(__name__)