From f01d7f0e165cd565680c04739a96511e869d29b4 Mon Sep 17 00:00:00 2001 From: Kylie Smith Date: Wed, 23 Aug 2023 09:24:25 +1000 Subject: [PATCH] Added legacy build Dockerfile --- .github/workflows/release.yml | 14 +++++++--- Dockerfile | 5 ---- Dockerfile-legacy | 49 +++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 Dockerfile-legacy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 567ef2d..32f4ef9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,12 +6,19 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} jobs: build-and-push-image: runs-on: ubuntu-latest + strategy: + matrix: + include: + - dockerfile: ./Dockerfile + image: ${{ env.REGISTRY }}/ksmit799/ardos + - dockerfile: ./Dockerfile-legacy + image: ${{ env.REGISTRY }}/ksmit799/ardos-legacy + permissions: contents: read packages: write @@ -31,14 +38,15 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + uses: docker/metadata-action@v4 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ matrix.image }} - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . + file: ${{ matrix.dockerfile }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 211f078..e6ffb56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,6 @@ RUN set -ex; \ apt-get update; \ apt-get install -y cmake g++ gcc curl libssl-dev; -# Setup directories. -WORKDIR /app -RUN mkdir build -RUN mkdir repos - # Install/build MongoDB C driver. WORKDIR /app/repos RUN curl -OL https://github.com/mongodb/mongo-c-driver/releases/download/1.24.3/mongo-c-driver-1.24.3.tar.gz diff --git a/Dockerfile-legacy b/Dockerfile-legacy new file mode 100644 index 0000000..8f62450 --- /dev/null +++ b/Dockerfile-legacy @@ -0,0 +1,49 @@ +FROM ubuntu:23.10 as build + +# Install dependencies. +RUN set -ex; \ + apt-get update; \ + apt-get install -y cmake g++ gcc curl libssl-dev; + +# Install/build MongoDB C driver. +WORKDIR /app/repos +RUN curl -OL https://github.com/mongodb/mongo-c-driver/releases/download/1.24.3/mongo-c-driver-1.24.3.tar.gz +RUN tar -xzf mongo-c-driver-1.24.3.tar.gz +WORKDIR /app/repos/mongo-c-driver-1.24.3/cmake-build +RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_TESTS=OFF +RUN cmake --build . --target install + +# Install/build MongoDB CXX driver. +WORKDIR /app/repos +RUN curl -OL https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.8.0/mongo-cxx-driver-r3.8.0.tar.gz +RUN tar -xzf mongo-cxx-driver-r3.8.0.tar.gz +WORKDIR /app/repos/mongo-cxx-driver-r3.8.0/build +RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_CXX_STANDARD=20 -DENABLE_TESTS=OFF +RUN cmake --build . --target install + +# Install/build Prometheus metrics. +WORKDIR /app/repos +RUN curl -OL https://github.com/jupp0r/prometheus-cpp/releases/download/v1.1.0/prometheus-cpp-with-submodules.tar.gz +RUN tar -xzf prometheus-cpp-with-submodules.tar.gz +WORKDIR /app/repos/prometheus-cpp-with-submodules/_build +RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_CXX_STANDARD=20 -DBUILD_SHARED_LIBS=ON -DENABLE_PUSH=OFF -DENABLE_COMPRESSION=OFF +RUN cmake --build . --target install + +# Copy source files. +COPY . /app + +# Build. +WORKDIR /app/build +RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DARDOS_USE_LEGACY_CLIENT=ON && make + +FROM ubuntu:23.10 + +# Copy the build artificat. +COPY --from=build /app/build/bin /app +COPY --from=build /usr/local/lib/lib* /usr/local/lib/ +COPY --from=build /app/build/libs/libuv/libuv.s* /usr/local/lib/ + +RUN ldconfig + +# Run. +ENTRYPOINT ["./app/ardos"]