fp/apps/opentracker/Dockerfile

89 lines
2.6 KiB
Docker
Raw Permalink Normal View History

2025-01-31 01:18:15 -08:00
#
# Based on wiltonsr/opentracker-docker @see https://github.com/wiltonsr/opentracker-docker/tree/main
# ours uses -DWANT_DYNAMIC_ACCESSLIST for incremental whitelist updates via named pipe
#
FROM gcc:14 AS compile-stage
RUN apt update ; \
apt install cvs -y
2025-02-19 13:09:53 -08:00
# @todo harden
# RUN adduser \
# --system --disabled-login \
# --uid 6969 --group \
# --home /etc/opentracker \
# farmhand
2025-01-31 01:18:15 -08:00
RUN adduser \
2025-02-19 13:09:53 -08:00
--system \
2025-01-31 01:18:15 -08:00
--uid 6969 --group \
--home /etc/opentracker \
farmhand
2025-02-19 13:09:53 -08:00
2025-01-31 01:18:15 -08:00
WORKDIR /usr/src
2025-02-15 04:31:20 -08:00
2025-01-31 01:18:15 -08:00
# Run libowfat compilation in separated layer to benefit from docker layer cache
RUN cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat ; \
git clone git://erdgeist.org/opentracker ; \
cd /usr/src/libowfat ; \
make
# http://erdgeist.org/arts/software/opentracker/#build-instructions
RUN cd /usr/src/opentracker ; \
# Build opentracker statically to use it in scratch image
LDFLAGS=-static make \
FEATURES+=-DWANT_FULLSCRAPE \
FEATURES+=-DWANT_FULLLOG_NETWORKS \
FEATURES+=-DWANT_LOG_NUMWANT \
FEATURES+=-DWANT_MODEST_FULLSCRAPES \
FEATURES+=-DWANT_SPOT_WOODPECKER \
FEATURES+=-DWANT_ACCESSLIST_WHITE \
FEATURES+=-DWANT_DYNAMIC_ACCESSLIST \
;\
bash -c 'mkdir -pv /tmp/stage/{etc/opentracker,bin}' ; \
cp -v opentracker.conf.sample /tmp/stage/etc/opentracker/opentracker.conf ; \
# Opentrack configuration file
sed -ri \
-e 's!(.*)(tracker.user)(.*)!\2 farmhand!g;' \
2025-02-19 13:09:53 -08:00
-e 's!(.*)(access.fifo_add)(.*)!\2 /etc/opentracker/adder.fifo!g;' \
2025-01-31 01:18:15 -08:00
-e 's!(.*)(access.whitelist)(.*)!\2 /etc/opentracker/whitelist!g;' \
2025-02-19 13:09:53 -08:00
-e '/^\s*#/d;/^\s*$/d' \
2025-01-31 01:18:15 -08:00
/tmp/stage/etc/opentracker/opentracker.conf ; \
install -m 755 opentracker.debug /tmp/stage/bin ; \
2025-02-15 04:31:20 -08:00
make DESTDIR=/tmp/stage BINDIR="/bin" install ; \
mkfifo /tmp/stage/etc/opentracker/adder.fifo
2025-01-31 01:18:15 -08:00
FROM alpine
2025-02-19 13:09:53 -08:00
RUN apk add curl tini
2025-01-31 01:18:15 -08:00
COPY --from=compile-stage /tmp/stage /
COPY --from=compile-stage /etc/passwd /etc/passwd
2025-02-15 04:31:20 -08:00
2025-02-19 13:09:53 -08:00
# da4f5b7724bb17e32f8a38792b007f316b33e962 -- test-fixture.ts
# We have some acceptance tests which depend on this info_hash being present in the whitelist.
RUN echo "da4f5b7724bb17e32f8a38792b007f316b33e962" >> /etc/opentracker/whitelist
# adder.fifo gets 0666 perms so tracker-helper (separate container) can write
RUN touch /etc/opentracker/whitelist
2025-02-15 04:31:20 -08:00
RUN chown -R 6969:6969 /etc/opentracker ; \
chmod 0664 /etc/opentracker/whitelist ; \
2025-02-19 13:09:53 -08:00
chmod 0666 /etc/opentracker/adder.fifo
2025-01-31 01:18:15 -08:00
WORKDIR /etc/opentracker
2025-02-15 04:31:20 -08:00
USER 6969
EXPOSE 6969/udp
EXPOSE 6969/tcp
2025-02-19 13:09:53 -08:00
HEALTHCHECK --interval=5s --timeout=3s --retries=3 \
2025-02-15 04:31:20 -08:00
CMD curl -f http://localhost:6969/stats || exit 1
2025-02-19 13:09:53 -08:00
ENTRYPOINT ["tini", "--", "/bin/opentracker"]
2025-02-15 04:31:20 -08:00
CMD ["-f", "/etc/opentracker/opentracker.conf"]