Skip to content

Commit

Permalink
Add docker file
Browse files Browse the repository at this point in the history
This makes the app a lot easier to deploy and to self host. ^^
  • Loading branch information
flofriday committed Aug 21, 2023
1 parent bc6e93d commit d755fc7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bettercal.db
.venv/
node_modules/
__pycache__/
.github/
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:latest as tailwindbuild
WORKDIR /app
COPY . .
RUN npm install
RUN npx tailwindcss -i templates/template.css -o static/style.css

FROM python:latest as pythonbuild
WORKDIR /app
COPY --from=tailwindbuild /app .
RUN pip install -r requirements.txt

ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ flag to the tailwind command.
**Warning:** The flask server here cannot be used in production and is optimized
for development comfort.

## Build with Docker

```bash
docker build -t bettercal .
docker run -it --rm -p 5000:5000 bettercal
```

The server should now start at http://localhost:5000

This approach can be used in production. However, statistics will die with the
container, but they can be preserved by adding the
`--mount type=bind,source="$(pwd)"/bettercal.db,target=/app/bettercal.db` argument to the
`docker run` command.

## How we deploy

In production we use the [gunicorn](https://gunicorn.org/) server.
Expand Down

0 comments on commit d755fc7

Please sign in to comment.