Skip to content

Commit 1b7fac7

Browse files
committed
Add waitress and resolve port conflict
Signed-off-by: eyuen <eyuen@redhat.com>
1 parent 0cb25e3 commit 1b7fac7

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from flask import Flask
2+
from waitress import serve
23

34
app = Flask(__name__)
45

5-
66
@app.route('/')
77
def hello():
88
return "Hello World!"
99

1010
if __name__ == '__main__':
11-
app.run(port=8080,host='0.0.0.0')
11+
serve(app, host='0.0.0.0', port=8080)

devfile.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ components:
1818
image: buildguidanceimage-placeholder
1919
memoryLimit: 1024Mi
2020
endpoints:
21-
- name: http-8080
22-
targetPort: 8080
21+
- name: http-8081
22+
targetPort: 8081
2323
- name: py-web
2424
container:
2525
image: quay.io/eclipse/che-python-3.7:nightly

docker/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
#
88
# Then run the container using:
99
#
10-
# docker run -i --rm -p 8080:8080 python/sample-basic
10+
# docker run -i --rm -p 8081:8081 python/sample-basic
1111
####
1212
FROM python:slim
1313

1414
WORKDIR /projects
15-
COPY . .
15+
16+
COPY requirements.txt requirements.txt
1617

1718
RUN python3 -m venv venv
1819
RUN . venv/bin/activate
1920
RUN pip install -r requirements.txt
2021

21-
EXPOSE 8080
22-
CMD [ "python", "app.py"]
22+
COPY . .
23+
24+
EXPOSE 8081
25+
CMD [ "waitress-serve", "--port=8081", "app:app"]
2326

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
Flask==1.1.2
2+
waitress==2.0.0

0 commit comments

Comments
 (0)