Skip to content

Commit ba87c38

Browse files
committed
docker: run sync by default, and add send/recv modes
1 parent cd720eb commit ba87c38

File tree

3 files changed

+78
-10
lines changed

3 files changed

+78
-10
lines changed

Dockerfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ RUN apt-get update && \
77
apt-get install --yes git mercurial curl vim && \
88
apt-get -q --yes autoremove && \
99
apt-get clean && \
10-
rm -rf /root/.cache
10+
rm -rf /root/.cache && \
11+
rm -rf /var/lib/apt/lists/*
1112

1213
WORKDIR /app
1314

1415
# git-cinnabar
1516
COPY install_git-cinnabar.sh .
16-
RUN ./install_git-cinnabar.sh
17-
RUN mv git-cinnabar git-remote-hg /usr/bin/
17+
RUN ./install_git-cinnabar.sh \
18+
&& mv git-cinnabar git-remote-hg /usr/bin/
1819

1920
# install test dependencies
2021
RUN pip install -U pip pytest pytest-mock pip-tools
@@ -23,10 +24,13 @@ RUN pip install -U pip pytest pytest-mock pip-tools
2324
# rebuild
2425
COPY --chown=app:app README.md .
2526
COPY --chown=app:app pyproject.toml .
26-
RUN pip-compile --verbose pyproject.toml
27-
RUN pip install -r requirements.txt
27+
RUN pip-compile --verbose pyproject.toml \
28+
&& pip install -r requirements.txt
2829

2930
# copy app and install
3031
COPY --chown=app:app . /app
3132
RUN pip install /app
3233
USER app
34+
35+
ENTRYPOINT ["/usr/local/bin/git-hg-sync"]
36+
CMD ["--config", "config-docker.toml"]

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,45 @@ to produce the equivalent mercurial commits to the right repo (depending on the
1818
It finally pushes the changes to the remote mercurial repository… then goes back to step one to
1919
process the next message in the queue.
2020

21-
## build and test
21+
## Run
22+
23+
```console
24+
$ docker compose up -d
25+
```
26+
27+
The logs from the syncer can be displayed with
28+
29+
```console
30+
$ docker compose logs -f sync
31+
```
32+
33+
XXX: queue config
34+
35+
```
36+
rabbitmqadmin declare exchange name=exchange/git-hg-sync/test type=direct
37+
rabbitmqadmin declare queue name=queue/git-hg-sync/sync durable=true
38+
rabbitmqadmin declare binding source=exchange/git-hg-sync/test destination=queue/git-hg-sync/sync routing_key=git-hg-sync
39+
```
40+
41+
The AMQP exchange is available at localhost:5672. To send a message, you can do the following
42+
43+
```console
44+
$ docker compose run --rm send
45+
<enter payload here>
46+
```
47+
48+
The message can be received with
49+
50+
```console
51+
$ docker compose run --rm recv
52+
```
53+
54+
XXX: example of test message
55+
56+
The RabbimMQ management interface is available at http://localhost:15672/, and
57+
the login and password are `guest` (don't do this at home, or in prod).
58+
59+
## Build and test
2260

2361
Format and test/lint code:
2462

@@ -29,7 +67,7 @@ $ tox -e format,lint
2967
Run tests:
3068

3169
```console
32-
$ docker compose run --build sync
70+
$ docker compose run --rm test
3371
$ docker compose down
3472
```
3573

docker-compose.yaml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
services:
2-
sync:
2+
sync: &sync_config
3+
image: git_hg_sync
34
build: .
4-
command: ['pytest', '--junitxml=./tests_output/pytest.xml', 'tests/']
55
volumes:
6-
- ./tests_output:/app/tests_output
6+
- .:/app
7+
- ./tests_output:/app/tests_output:z
78
environment:
89
- RABBITMQ=true
910
depends_on:
@@ -12,6 +13,31 @@ services:
1213
networks:
1314
- pulse_network
1415

16+
send:
17+
image: rabbitmq:3-management-alpine
18+
entrypoint: rabbitmqadmin publish --host pulse exchange=exchange/git-hg-sync/test routing_key=git-hg-sync
19+
profiles:
20+
- send
21+
networks:
22+
- pulse_network
23+
24+
recv:
25+
image: rabbitmq:3-management-alpine
26+
entrypoint: rabbitmqadmin get --host pulse queue=queue/git-hg-sync/sync
27+
profiles:
28+
- recv
29+
networks:
30+
- pulse_network
31+
32+
test:
33+
<<: *sync_config
34+
command: ["--junitxml=/tmp/tests_output/pytest.xml", "tests/"]
35+
entrypoint: pytest
36+
profiles:
37+
- test
38+
networks:
39+
- pulse_network
40+
1541
pulse:
1642
image: rabbitmq:3-management-alpine
1743
healthcheck:

0 commit comments

Comments
 (0)