Skip to content

Commit 04dcf42

Browse files
committed
added env var for port number
Signed-off-by: Paul Schultz <[email protected]>
1 parent 524713f commit 04dcf42

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from flask import Flask
2+
import os
23

34
app = Flask(__name__)
45

@@ -7,4 +8,9 @@ def hello():
78
return "Hello World!"
89

910
if __name__ == '__main__':
10-
app.run(port=8080,host='0.0.0.0')
11+
port = int(os.environ.get('FLASK_PORT'))
12+
13+
if port == None:
14+
port = 8080
15+
16+
app.run(port=port,host='0.0.0.0')

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM python:slim
22

33
# By default, listen on port 8081
44
EXPOSE 8081/tcp
5+
ENV FLASK_PORT=8081
56

67
# Set the working directory in the container
78
WORKDIR /projects

0 commit comments

Comments
 (0)