Skip to content

Commit

Permalink
dockerize running app
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed Mar 15, 2020
1 parent ebaa51c commit c848b55
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT=8000
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.7.7-buster

WORKDIR /app

COPY ./requirements.txt /app/requirements.txt

RUN pip install -r requirements.txt

COPY . ./

RUN chmod u+x setup.sh && PORT=8000 ./setup.sh

# expanding shell variables in CMD is tricky, see
# https://stackoverflow.com/questions/23071214/use-environment-variables-in-cmd
CMD ["streamlit", "run", "--server.port", "8000", "app.py"]
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ To test the app locally just run:

This will open a browser window with the app running.

### Developing with docker

Copy `.env.example` to be `.env` and run the container.

```bash
cp .env.example .env
docker-compose up
```

You should be able to view the app via `localhost:8000`. If you want to change the
port, then set `PORT` in the `.env` file.

## Deployment
**Before you push your changes to master make sure that everything works in development mode.**

Changes merged to `master` will be automatically deployed to [pennchime.herokuapp.com](https://pennchime.herokuapp.com/).
Changes merged to `master` will be automatically deployed to [pennchime.herokuapp.com](https://pennchime.herokuapp.com/).
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.1'

services:
app:
build: .
restart: always
ports:
- "${PORT}:8000"

0 comments on commit c848b55

Please sign in to comment.