Skip to content

Commit

Permalink
GH-1: Build Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
markhobson committed Sep 15, 2023
1 parent b1effcc commit b4d9105
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ jobs:

- name: Run tests
run: pytest

- name: Build image
uses: docker/build-push-action@v4
with:
tags: schemes
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.10

ENV PORT 5000

WORKDIR /usr/src/app
COPY schemes ./schemes
COPY pyproject.toml .

RUN pip install --no-cache-dir .

CMD [ "sh", "-c", "gunicorn --bind 0.0.0.0:${PORT} 'schemes:create_app()'" ]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@

1. Open http://127.0.0.1:5000

## Running locally as a container

1. Build the Docker image:

```bash
docker build -t schemes .
```

1. Run the Docker image:

```bash
docker run --rm -it -p 5000:5000 schemes
```

1. Open http://127.0.0.1:5000

The server can also be run on a different port by specifying the `PORT` environment variable:

```bash
docker run --rm -it -e PORT=8000 -p 8000:8000 schemes
```

## Running tests

1. Install the dev dependencies:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name = "schemes"
version = "1.0.0"
dependencies = [
"flask"
"flask",
"gunicorn"
]

[project.optional-dependencies]
Expand Down

0 comments on commit b4d9105

Please sign in to comment.