How can I host my backend flask app on heroku? - postgresql

I have a reach app acting as the frontend and a flask app acting as the backend.
I hosted the frontend on heroku. The problem is with the backend.
When ever I deploy it on heroku it builds fine but I always get The below.
when I check the logs, I see the below.
I'm not sure what the issue is but I am thinking its in models file.
database_path = os.environ['DATABASE_URL']
db = SQLAlchemy()
def setup_db(app, database_path=database_path):
if database_path.startswith("postgres://"):
database_path = database_path.replace("postgres://", "postgresql://", 1)
app.config["SQLALCHEMY_DATABASE_URI"] = database_path
engine = sqlalchemy.create_engine(database_path)
if not database_exists(engine.url):
create_database(engine.url)
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db.app = app
db.init_app(app)
db.create_all()
Any ideas?
if I didnt include enough information I apologize, I am brand new to running my web pages outside of my local machine.
EDIT:
I created procfile and added
web: gunicorn flaskr:app
new log is
my app structure is

First Try this in while deploying
heroku addons:create heroku-postgresql:hobby-dev
If that doesn't fix it, try the below
It looks from the logs that you have not configured the dynamo properly in your Procfile. Use gunicorn and try adding this to your Profile web: gunicorn app:app. This should fix the problem. If not, as you are using postgresql, it would be helpful if you download the heroku addon for postgresql from here
This should fix your problem. If Not, below listed are all the steps for deploying a heroku app. Please check if you followed all the below steps properly and in order.
For Flask I recommend doing the following things
Download heroku cli
Start a virtual environment with python -m venv . in your project fil
Activate the virtual environment
Login to your heroku account in the cli with heroku login
Install gunicorn pip install gunicorn
In your virtual environment, install the modules again with pip
Create a requirements.txt with pip freeze > requirements.txt
Create "Procfile" with the following info web: gunicorn app:app, this will fix the dynamo problem in the log
Start a empty git repository with git init
Create a appropiate .gitignore, you can find the template here
Create a new heroku app with heroku create my-app-flask
Add files to heroku git, git add .
As You are using postgresql, it would be helpful if you download the heroku addon for your app Get it here
Finally, git commit -m "Message" and git push heroku master
This should fix your problem.

Related

how can i deploy scala on heroku

i am following this link to deploy scala into heroku.
but i got H14 error in heroku - "no web processes running"
i found in internet i must have dyno active heroku ps:scale web=1
but this service is not free. to be valid user, we must enter credit card on heroku.
that meant Heroku is not free anymore ?
so how can i deploy scala API on heroku for free ?
my Procfile : web: target/universal/stage/bin/conspille2
my sbt
did i put Procfile in the right folder. it said on Root.
it is ambigue in root like i did or in root of app ?

Trouble with dev environment Shopify App in Docker containers with ngrok tunnel

I installed new Shopify App by Shopify CLI command shopify app create (PHP (Laravel) and React stack).
Now I want run this project with Docker (nginx, fpm, mysql containers) in docker-compose file.
Nginx working on --port=8081 because it's requirement of ngrok tunnel.
So my commands step by step:
npm run watch (for React files)
shopify app serve (done)
docker containers already started, nginx on port 8081
After command shopify app serve I get link ngrok tunnel, follow it and in browser in console
enter image description here
Why? Perhaps there are features of listening Docker containers by ngrok? app.js file really exist in /public folder of my project.
Can you share a guide how to develop shopify app in Docker env?
What a files of my project I should share preview here for completing mi trouble? Thanks!

How to set up a docker-compose and Dockerfile to deploy a Laravel app?

I recently finished developing a Laravel 9 app, using wsl2 and sail, just like I was told in the Laravel documentation. Since it’s my first time deploying to live ever, I ran into some differences with local and production files such as .env, docker-compose.yml and Dockerfile.
I tried using guides and tutorials but I can’t seem to make sense as to how to make it work. I have a droplet with a non-root user with sudo privileges, since I used these two kind guides:
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04
after finishing with the installation, I tried to clone my app and run it like I do locally, and nothing happened. I realize I can’t use sail on the server, but what is the correct way to make it work?
All three local files (.env, docker-compose.yml and Dockerfile) were never edited.
use this repository docker-laravel
i have Php, Composer, and mariadb on it.

drools workbench in cloudfoundry.

I am trying to deploy drools workbench in cloudfoundry. I am not able to push a docker image to my company's CF env, but these docker images works in my local PCF Dev.
So, I pushed a war file to my CF env.
cf push kie -p kie-drools-wb-distribution-wars-6.4.0.Final-wildfly8.war -b jboss-buildpack-offline -m 2g -k 2g -t 180
the application is running in CF. But I am not sure how to get launch the application, to see login page and workbench.
Please help.
Looking at the Dockerfile for drools-workbench (https://hub.docker.com/r/jboss/drools-workbench/~/dockerfile/) it appears to start the workbench using bin/start_drools-wb.sh file, however the JBoss buildpack appears to start the application using standalone.sh
Perhaps you should look at how the application should be started and adapt the start command.

Deploying Treeline

I'm trying to deploy a Treeline app on my Ubuntu/Digital Ocean server with no luck.
I have worked successfully with sails (using "forever") before and tried to install treeline the same way.
npm install treeline -g
But after the installation, when trying to do something else, it always returns:
treeline.py: cannot connect to X server
I don't know if this error is due to my lack of experience deploying node or the earlier stage of the treeline project (which, on the other hand, is really awesome).
Thank you in advance.
Deploying a Treeline app is exactly the same as deploying a Sails app, because the files that get synched down from the Treeline server are Sails apps--they were just generated for you instead of you having to write the code. You don't need to npm install treeline -g on your server; that's only for previewing your app locally as you make changes to it on treeline.io. Instead, when you're ready to deploy, just follow whatever procedure that worked for your previous Sails apps and it will work for your Treeline app.
As far as the treeline.py error--that appears to be coming from a conflicting file pre-installed on Ubuntu!