From b638b4bd3853ba31c1d650b8f9f2df1dd7544745 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sun, 18 Aug 2024 17:14:42 +0200 Subject: [PATCH] docker: use separate repo for builder this avoids unnecessary caching / rebuilds --- .github/workflows/docker.yaml | 10 ++++---- Dockerfile | 43 ++++++++--------------------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 2620f896..f8776a1e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -2,12 +2,10 @@ name: docker build on: schedule: - - cron: "0 10 * * *" + - cron: "0 5 * * 1" push: branches: - - "**" - tags: - - "v*.*.*" + - "dev" pull_request: branches: - "dev" @@ -21,8 +19,8 @@ jobs: - name: Set variables useful for later id: useful_vars run: |- - echo "::set-output name=timestamp::$(date +%s)" - echo "::set-output name=short_sha::${GITHUB_SHA::8}" + echo "name=timestamp::$(date +%s)" >> $GITHUB_OUTPUT + echo "name=short_sha::${GITHUB_SHA::8}" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@v3 - name: Docker meta diff --git a/Dockerfile b/Dockerfile index 34b6c1fb..8f4b3092 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,5 @@ -FROM debian:bookworm-slim AS builder -RUN apt-get update && \ - apt-get install --no-install-recommends -y \ - git \ - wget \ - pkg-config \ - autoconf \ - gcc \ - make \ - libusb-1.0-0-dev \ - librtlsdr-dev \ - libncurses-dev \ - zlib1g-dev \ - libzstd-dev \ - ca-certificates +FROM ghcr.io/wiedehopf/readsb-builder:latest AS builder -# install jemalloc -RUN JEMALLOC_BDIR=$(mktemp -d) && \ - git clone --depth 1 https://github.com/jemalloc/jemalloc $JEMALLOC_BDIR && \ - cd $JEMALLOC_BDIR && \ - ./autogen.sh && \ - ./configure --with-lg-page=14 && \ - make -j$(nproc) && \ - make install && \ - rm -rf $JEMALLOC_BDIR - -# install readsb SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"] RUN --mount=type=bind,source=.,target=/app/git \ cd /app/git && \ @@ -48,18 +23,20 @@ RUN --mount=type=bind,source=.,target=/app/git \ true FROM debian:bookworm-slim -RUN apt-get update && \ +RUN \ + --mount=type=bind,from=builder,source=/,target=/builder/ \ + apt-get update && \ apt-get -y install --no-install-recommends \ - wget \ librtlsdr0 libncurses6 zlib1g libzstd1 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ - mkdir -p /run/readsb + mkdir -p /run/readsb && \ + cp /builder/usr/local/bin/readsb* /usr/local/bin/ && \ + cp /builder/usr/local/bin/viewadsb* /usr/local/bin/ && \ + cp /builder/usr/local/share/tar1090/aircraft.csv.gz /usr/local/share/tar1090/aircraft.csv.gz && \ + cp /builder/usr/local/lib/libjemalloc.so.2 /usr/local/lib/libjemalloc.so.2 && \ + true ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so.2 -COPY --from=builder /usr/local/bin/readsb* /usr/local/bin/ -COPY --from=builder /usr/local/bin/viewadsb* /usr/local/bin/ -COPY --from=builder /usr/local/share/tar1090/aircraft.csv.gz /usr/local/share/tar1090/aircraft.csv.gz -COPY --from=builder /usr/local/lib/libjemalloc.so.2 /usr/local/lib/libjemalloc.so.2 ENTRYPOINT ["/usr/local/bin/readsb"]