Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
add Dockerfile for local development without python
Browse files Browse the repository at this point in the history
- Add a Dockerfile to run the application without needing to install any python dependencies (or even python itself!)
- Update app.py to bind to 0.0.0.0 in DEV mode so it can respond inside a container
- Update Contributing.md with instructions for building and running a containerized version of the webapp
  • Loading branch information
lpmi-13 committed May 5, 2021
1 parent 8317cc3 commit a699bad
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
.github
*.md
.dockerignore
Dockerfile
License.txt
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ you can wrap the command in a loop to restart the server quickly).
(.env)$ env FLASK_ENV=development python app.py
# or in a loop if it stops too often
(.env)$ while true; do env FLASK_ENV=development python app.py; sleep 1; done

If you want to run the website locally, but would prefer to use Docker instead of installing python, you can build a container and run it like so:
```bash
docker build -t NAME_OF_CONTAINER .
```
and then
```bash
docker run -it --rm -p 5000:5000 NAME_OF_CONTAINER
```

If you don't want to use a website, you can run the code locally without the need of a website. To create a file use:
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:20.04

RUN apt update -y && apt install -y python3.8 python3-pip

COPY requirements.txt /tmp/requirements.txt

RUN pip3 install -r /tmp/requirements.txt

WORKDIR /app

COPY . .

EXPOSE 5000

ENTRYPOINT ["python3.8", "app.py"]
5 changes: 4 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,7 @@ def update_yaml():

if __name__ == '__main__':
# Threaded option to enable multiple instances for multiple user access support
app.run(threaded=True, port=config ['port'])
if version() == 'DEV':
app.run(threaded=True, port=config ['port'], host="0.0.0.0")
else:
app.run(threaded=True, port=config ['port'])

0 comments on commit a699bad

Please sign in to comment.