Skip to content

Commit c848b55

Browse files
committed
dockerize running app
1 parent ebaa51c commit c848b55

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PORT=8000

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.7.7-buster
2+
3+
WORKDIR /app
4+
5+
COPY ./requirements.txt /app/requirements.txt
6+
7+
RUN pip install -r requirements.txt
8+
9+
COPY . ./
10+
11+
RUN chmod u+x setup.sh && PORT=8000 ./setup.sh
12+
13+
# expanding shell variables in CMD is tricky, see
14+
# https://stackoverflow.com/questions/23071214/use-environment-variables-in-cmd
15+
CMD ["streamlit", "run", "--server.port", "8000", "app.py"]

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ To test the app locally just run:
77

88
This will open a browser window with the app running.
99

10+
### Developing with docker
11+
12+
Copy `.env.example` to be `.env` and run the container.
13+
14+
```bash
15+
cp .env.example .env
16+
docker-compose up
17+
```
18+
19+
You should be able to view the app via `localhost:8000`. If you want to change the
20+
port, then set `PORT` in the `.env` file.
21+
1022
## Deployment
1123
**Before you push your changes to master make sure that everything works in development mode.**
1224

13-
Changes merged to `master` will be automatically deployed to [pennchime.herokuapp.com](https://pennchime.herokuapp.com/).
25+
Changes merged to `master` will be automatically deployed to [pennchime.herokuapp.com](https://pennchime.herokuapp.com/).

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3.1'
2+
3+
services:
4+
app:
5+
build: .
6+
restart: always
7+
ports:
8+
- "${PORT}:8000"

0 commit comments

Comments
 (0)