Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit 9008e40

Browse files
youming-linYouming Lin
and
Youming Lin
authored
Promote (#73)
* exposer port in Dockerfile (#71) * Use PORT env var (e.g. in Code Engine environment) (#72) Co-authored-by: Youming Lin <[email protected]> Co-authored-by: Youming Lin <[email protected]>
1 parent 830d23b commit 9008e40

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ USER 1001
1717

1818
COPY . /app
1919
ENV FLASK_APP=server/__init__.py
20-
CMD ["python3", "manage.py", "start", "0.0.0.0:3000"]
20+
ENV PORT 3000
21+
22+
EXPOSE 3000
23+
24+
CMD ["python3", "manage.py", "start"]

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ Running Flask applications has been simplified with a `manage.py` file to avoid
5656
pipenv install
5757
```
5858

59-
To run your application locally:
59+
Then, activate this app's virtualenv:
60+
61+
```bash
62+
pipenv shell
63+
```
64+
65+
To run your application locally, run this inside the virtualenv:
6066

6167
```bash
6268
python manage.py start

manage.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import os, sys, argparse, subprocess, signal
22

3+
# Tip from:
4+
# https://github.com/dpgaspar/Flask-AppBuilder/issues/733#issuecomment-379009480
5+
PORT = int(os.environ.get("PORT", 3000))
6+
37
# Project defaults
48
FLASK_APP = 'server/__init__.py'
5-
DEFAULT_IP = '0.0.0.0:3000'
6-
9+
DEFAULT_IP = '0.0.0.0:' + str(PORT)
710

811
class Command:
912
def __init__(self, name, descr, runcmd, env={}):
@@ -99,7 +102,7 @@ def availableCommands(self):
99102
formatter_class=argparse.RawDescriptionHelpFormatter)
100103
parser.add_argument("subcommand", help="subcommand to run (see list above)")
101104
parser.add_argument("ipaddress", nargs='?', default=DEFAULT_IP,
102-
help="address and port to run on (i.e. {0})".format(DEFAULT_IP))
105+
help="address and port to run on (i.e. 0.0.0.0:3000)")
103106

104107

105108
def livereload_check():

0 commit comments

Comments
 (0)