Auto-download BRouter segments on first container start
Fresh `pnpm dev:services` checkouts came up with an empty brouter_segments volume, so every routing request returned "datafile not found" and the e2e suite's BRouter tests failed. Add an entrypoint that runs download-segments.sh when /data/segments has no rd5 files, then exec's the existing server command. Subsequent starts find the populated volume and skip straight to the server. Keep wget in the final image (previously stripped) so the entrypoint can fetch segments at runtime. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f1963aab7a
commit
46743a91db
2 changed files with 30 additions and 7 deletions
|
|
@ -10,11 +10,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends wget unzip curl
|
|||
&& mv "brouter-${BROUTER_VERSION}"/* . \
|
||||
&& rmdir "brouter-${BROUTER_VERSION}" \
|
||||
&& rm "brouter-${BROUTER_VERSION}.zip" \
|
||||
&& apt-get purge -y wget unzip && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
||||
&& apt-get purge -y unzip && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user and directories for segments and profiles
|
||||
RUN addgroup --system app && adduser --system --ingroup app app \
|
||||
&& mkdir -p /data/segments /data/profiles
|
||||
&& mkdir -p /data/segments /data/profiles \
|
||||
&& chown -R app:app /data
|
||||
|
||||
# Install entrypoint + segment downloader
|
||||
COPY download-segments.sh /brouter/download-segments.sh
|
||||
COPY entrypoint.sh /brouter/entrypoint.sh
|
||||
RUN chmod +x /brouter/download-segments.sh /brouter/entrypoint.sh
|
||||
|
||||
# Copy default profiles from release and rename JAR for simpler CMD
|
||||
RUN cp -r profiles2/* /data/profiles/ 2>/dev/null || true \
|
||||
|
|
@ -45,9 +51,10 @@ ENV JAVA_OPTS="-Xmx1024M -Xms256M -Xmn64M"
|
|||
# sets it to 16; flagship/CI keep the default.
|
||||
ENV BROUTER_THREADS=4
|
||||
|
||||
# Entrypoint downloads segments on first start if /data/segments is empty,
|
||||
# then execs the CMD. Shell form on CMD so $JAVA_OPTS / $BROUTER_THREADS
|
||||
# expand at container start.
|
||||
ENTRYPOINT ["/brouter/entrypoint.sh"]
|
||||
|
||||
# BRouter server: <segmentdir> <profiledir> <customprofiledir> <port> <maxthreads>
|
||||
# Shell form so $JAVA_OPTS and $BROUTER_THREADS expand at container start.
|
||||
CMD java $JAVA_OPTS -DmaxRunningTime=300 -cp brouter.jar \
|
||||
btools.server.RouteServer \
|
||||
/data/segments /data/profiles /data/profiles \
|
||||
17777 $BROUTER_THREADS
|
||||
CMD ["sh", "-c", "java $JAVA_OPTS -DmaxRunningTime=300 -cp brouter.jar btools.server.RouteServer /data/segments /data/profiles /data/profiles 17777 $BROUTER_THREADS"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue