Skip to content

Adding environment port variable#2748

Merged
leahecole merged 2 commits into
masterfrom
cloud-run-local
Jan 27, 2020
Merged

Adding environment port variable#2748
leahecole merged 2 commits into
masterfrom
cloud-run-local

Conversation

@dinagraves
Copy link
Copy Markdown
Contributor

To run locally, the PORT environment variable needs to be set.

@dinagraves dinagraves requested review from a team and averikitsch as code owners January 23, 2020 23:31
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 23, 2020
@averikitsch
Copy link
Copy Markdown
Contributor

Does this mean we should remove the if os.getenv("PORT") else 8080 from the main.py?

@dinagraves
Copy link
Copy Markdown
Contributor Author

dinagraves commented Jan 24, 2020

Does this mean we should remove the if os.getenv("PORT") else 8080 from the main.py?

No, this is only for if you want to run the docker image locally. Without the PORT variable set, the container won't start! This is because of the line in the Dockerfiles: CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 main:app

You can still run the python file outside of a docker image, in which case, you need the getenv, eg: python main.py

@leahecole
Copy link
Copy Markdown
Collaborator

Once this passes the appropriate CI, I'll merge it in! I know that this uses f strings and we previously said that was okay for it to fail earlier python versions. :)

@leahecole leahecole merged commit a2e4e81 into master Jan 27, 2020
@leahecole leahecole deleted the cloud-run-local branch January 27, 2020 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants