Skip to content

Commit 67d7d97

Browse files
committed
Add a basic Dockerfile and document how to run it against aiven infra
1 parent 8a23db9 commit 67d7d97

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.8-slim-buster
2+
3+
RUN ["mkdir", "-p", "/checkweb"]
4+
WORKDIR /src
5+
6+
RUN groupadd -r checkweb && useradd --no-log-init -r -g checkweb checkweb
7+
8+
COPY ./src/ /src/
9+
COPY requirements.txt.freeze /src/
10+
11+
RUN true \
12+
&& pip install --upgrade pip \
13+
&& pip install --no-cache-dir -r requirements.txt.freeze
14+
15+
USER checkweb
16+
17+
# start by default as producer
18+
ENTRYPOINT ["python3", "-m", "checkweb"]
19+
CMD ["producer"]

Makefile

+26
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,29 @@ run-%-aiven: aiven.env
5858

5959
integration-tests-aiven: start-infra-aiven
6060
CHECKWEB_ENV_PATH=aiven.env .venv/bin/python3 ./integration_tests.py
61+
62+
build-docker:
63+
docker build -t checkweb:latest -f ./Dockerfile .
64+
65+
run-docker-aiven:
66+
make -j run-docker-aiven-producer run-docker-aiven-consumer
67+
make show-docker-logs
68+
69+
run-docker-aiven-%:
70+
docker run -itd --rm --name checkweb-$* --env-file=aiven.env --env KAFKA_CERT_PATH=/ \
71+
-v "$(CURDIR)"/service.cert:/service.cert \
72+
-v "$(CURDIR)"/service.key:/service.key \
73+
-v "$(CURDIR)"/ca.pem:/ca.pem \
74+
checkweb:latest $*
75+
76+
show-docker-logs:
77+
make -j show-docker-logs-producer show-docker-logs-consumer
78+
79+
show-docker-logs-%:
80+
docker logs -f checkweb-$*
81+
82+
stop-docker:
83+
make -j stop-docker-producer stop-docker-consumer
84+
85+
stop-docker-%:
86+
docker stop checkweb-$*

README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ make stop-infra-aiven
7272

7373
Destroying the Infrastructure is only possible in the [Aiven UI](https://console.aiven.io/).
7474

75+
## Run locally in docker against aiven infrastructure
76+
77+
Build the Image:
78+
79+
```bash
80+
make build-docker
81+
```
82+
83+
Run the docker container in detached mode and then follow the logs of both containers. This expects a
84+
configured `aiven.env` file.
85+
86+
```bash
87+
make run-docker-aiven
88+
```
89+
90+
`ctrl+c` will stop following the log but not the containers!
91+
92+
To shutdown both container:
93+
94+
```bash
95+
make stop-docker
96+
```
97+
7598
## Maintainance
7699

77100
### Updating or installing new python packages
@@ -108,7 +131,7 @@ Afterwards commit `requirements.txt` and `requirements.txt.freeze`.
108131
* [x] Implement an integration test which spins up new local infra, runs a few loops and then checks that the expected
109132
data is in the DB + the same check with failing websites
110133
* [x] Polish the code
111-
* [ ] Proper Packaging: dockerfile? setup.py?
134+
* [x] Proper Packaging: dockerfile? setup.py? -> just a Dockerfile for now
112135

113136
### Step 4: Connect to Aiven infra and document
114137
* [x] Figure out how to spin up the infra via `avn` and document it

0 commit comments

Comments
 (0)