Skip to content

Commit

Permalink
Using tini to handle signals
Browse files Browse the repository at this point in the history
- Add tini to correctly handle signal to opentracker
- Update to use gcc:14
- Update docs
  • Loading branch information
wiltonsr committed Feb 6, 2025
1 parent 98debfc commit 61fe38d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
9 changes: 7 additions & 2 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM gcc:11 as compile-stage
FROM gcc:14 as compile-stage

ARG TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
RUN chmod +x /tini

RUN apt update ; \
apt install cvs -y
Expand Down Expand Up @@ -35,6 +39,7 @@ RUN cd /usr/src/opentracker ; \

FROM scratch

COPY --from=compile-stage /tini /
COPY --from=compile-stage /tmp/stage /
COPY --from=compile-stage /etc/passwd /etc/passwd

Expand All @@ -45,5 +50,5 @@ USER 6969
EXPOSE 6969/udp
EXPOSE 6969/tcp

ENTRYPOINT ["/bin/opentracker"]
ENTRYPOINT ["/tini", "--", "/bin/opentracker"]
CMD ["-f", "/etc/opentracker/opentracker.conf"]
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ The `blacklist` and `whitelist` tags contains a Opentracker builded with `-DWANT

## Using in `open` Mode

The image has `/bin/opentracker` binary as [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) and `-f /etc/opentracker/opentracker.conf` as default [CMD](https://docs.docker.com/engine/reference/builder/#exec-form-entrypoint-example).
The image has `/tini -- /bin/opentracker` binary as [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) and `-f /etc/opentracker/opentracker.conf` as default [CMD](https://docs.docker.com/engine/reference/builder/#exec-form-entrypoint-example).

We use [tini](https://github.com/krallin/tini), a tiny but valid init for containers, to manage `PID 1` and correctly handle signals to `opentracker`.

So you can run:

Expand Down Expand Up @@ -55,17 +57,17 @@ Now you can access [Opentracker Stats page](https://erdgeist.org/arts/software/o

### Debug Mode

All `tags` also contains `/bin/opentracker.debug` binary. So you could run Opentracker in `debug mode` overriding default `ENTRYPOINT`.
All `tags` also contains `/bin/opentracker.debug` binary. So you could run Opentracker in `debug mode` overriding default `ENTRYPOINT` and `CMD`.

```bash
docker run \
--rm \
-d \
--name opentracker \
-p 6969:6969/udp -p 6969:6969 \
--entrypoint="/bin/opentracker.debug" \
--entrypoint="/tini" \
wiltonsr/opentracker:open \
-f /etc/opentracker/opentracker.conf
-- /bin/opentracker.debug -f /etc/opentracker/opentracker.conf
```

It is also possible to override the default command with:
Expand Down
9 changes: 7 additions & 2 deletions blacklist.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
FROM gcc:11 as compile-stage
FROM gcc:14 as compile-stage

ARG TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
RUN chmod +x /tini

RUN apt update ; \
apt install cvs -y
Expand Down Expand Up @@ -46,6 +50,7 @@ RUN cd /usr/src/opentracker ; \

FROM scratch

COPY --from=compile-stage /tini /
COPY --from=compile-stage /tmp/stage /
COPY --from=compile-stage /etc/passwd /etc/passwd

Expand All @@ -56,5 +61,5 @@ USER 6969
EXPOSE 6969/udp
EXPOSE 6969/tcp

ENTRYPOINT ["/bin/opentracker"]
ENTRYPOINT ["/tini", "--", "/bin/opentracker"]
CMD ["-f", "/etc/opentracker/opentracker.conf"]
9 changes: 7 additions & 2 deletions open.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
FROM gcc:11 as compile-stage
FROM gcc:14 as compile-stage

ARG TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
RUN chmod +x /tini

RUN apt update ; \
apt install cvs -y
Expand Down Expand Up @@ -45,6 +49,7 @@ RUN cd /usr/src/opentracker ; \

FROM scratch

COPY --from=compile-stage /tini /
COPY --from=compile-stage /tmp/stage /
COPY --from=compile-stage /etc/passwd /etc/passwd

Expand All @@ -55,5 +60,5 @@ USER 6969
EXPOSE 6969/udp
EXPOSE 6969/tcp

ENTRYPOINT ["/bin/opentracker"]
ENTRYPOINT ["/tini", "--", "/bin/opentracker"]
CMD ["-f", "/etc/opentracker/opentracker.conf"]
9 changes: 7 additions & 2 deletions whitelist.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
FROM gcc:11 as compile-stage
FROM gcc:14 as compile-stage

ARG TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
RUN chmod +x /tini

RUN apt update ; \
apt install cvs -y
Expand Down Expand Up @@ -46,6 +50,7 @@ RUN cd /usr/src/opentracker ; \

FROM scratch

COPY --from=compile-stage /tini /
COPY --from=compile-stage /tmp/stage /
COPY --from=compile-stage /etc/passwd /etc/passwd

Expand All @@ -56,5 +61,5 @@ USER 6969
EXPOSE 6969/udp
EXPOSE 6969/tcp

ENTRYPOINT ["/bin/opentracker"]
ENTRYPOINT ["/tini", "--", "/bin/opentracker"]
CMD ["-f", "/etc/opentracker/opentracker.conf"]

0 comments on commit 61fe38d

Please sign in to comment.