Skip to content

Commit

Permalink
fix(python)!: respect $PORT variable instead of to always listen on 8000
Browse files Browse the repository at this point in the history
Relate to #16
  • Loading branch information
php-coder committed Apr 24, 2024
1 parent db5b4c2 commit 2fc1114
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Generates the endpoints (or a whole app) from a mapping (SQL query -> URL)
| JavaScript | <pre>$ npm install<br/>$ export DB_NAME=my-db DB_USER=my-user DB_PASSWORD=my-password<br/>$ npm start</pre> |
| TypeScript | <pre>$ npm install<br/>$ npm run build<br/>$ export DB_NAME=my-db DB_USER=my-user DB_PASSWORD=my-password<br/>$ npm start</pre> |
| Golang | <pre>$ export DB_NAME=my-db DB_USER=my-user DB_PASSWORD=my-password<br/>$ go run *.go</pre>or<pre>$ go build -o app<br/>$ ./app</pre> |
| Python | <pre>$ pip install -r requirements.txt<br/>$ export DB_NAME=my-db DB_USER=my-user DB_PASSWORD=my-password<br/>$ uvicorn app:app</pre> |
| Python | <pre>$ pip install -r requirements.txt<br/>$ export DB_NAME=my-db DB_USER=my-user DB_PASSWORD=my-password<br/>$ uvicorn app:app --port 3000</pre> |
---
:bulb: **NOTE**
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ services:
- DB_HOST=postgres # defaults to localhost
- PORT=4040 # defaults to 3000
ports:
- '4040:8000'
- '4040:4040'
depends_on:
postgres:
condition: service_healthy
2 changes: 1 addition & 1 deletion examples/python/fastapi/postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ WORKDIR /opt/app
COPY requirements.txt ./
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY *.py ./
CMD [ "uvicorn", "app:app", "--host", "0.0.0.0" ]
CMD [ "sh", "-c", "exec uvicorn app:app --host 0.0.0.0 --port ${PORT:-3000}" ]
2 changes: 1 addition & 1 deletion src/templates/Dockerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
COPY requirements.txt ./
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY *.py ./
CMD [ "uvicorn", "app:app", "--host", "0.0.0.0" ]
CMD [ "sh", "-c", "exec uvicorn app:app --host 0.0.0.0 --port ${PORT:-3000}" ]

0 comments on commit 2fc1114

Please sign in to comment.