From 09a94e0db34cd332ca54ee20d671893a1537d16c Mon Sep 17 00:00:00 2001 From: Vibhav Bobade Date: Thu, 9 Feb 2023 17:55:35 +0530 Subject: [PATCH] optimize meilisearch uffizzi build even though docker cache was being used earlier for uffizzi builds, seems like the cache layers weren't persisting. This commit adds changes to move meilisearch building outside the dockerfile so that we can use the rust cache action. We are also building to the musl target so that the binary for meilisearch which is created can be used for the uffizzi ttyd image which uses alpine. --- .github/uffizzi/Dockerfile | 31 +------------------- .github/workflows/uffizzi-build.yml | 20 +++++++++++++ .github/workflows/uffizzi-preview-deploy.yml | 6 ++-- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/.github/uffizzi/Dockerfile b/.github/uffizzi/Dockerfile index 57ee4aa8d..a05b28a9c 100644 --- a/.github/uffizzi/Dockerfile +++ b/.github/uffizzi/Dockerfile @@ -1,24 +1,3 @@ -# Compile -FROM rust:alpine3.16 AS compiler - -RUN apk add -q --update-cache --no-cache build-base openssl-dev - -WORKDIR /meilisearch - -ARG COMMIT_SHA -ARG COMMIT_DATE -ARG GIT_TAG -ENV COMMIT_SHA=${COMMIT_SHA} COMMIT_DATE=${COMMIT_DATE} VERGEN_GIT_SEMVER_LIGHTWEIGHT=${GIT_TAG} -ENV RUSTFLAGS="-C target-feature=-crt-static" - -COPY . . -RUN set -eux; \ - apkArch="$(apk --print-arch)"; \ - if [ "$apkArch" = "aarch64" ]; then \ - export JEMALLOC_SYS_WITH_LG_PAGE=16; \ - fi && \ - cargo build --release - # Run FROM uffizzi/ttyd:alpine @@ -29,19 +8,11 @@ ENV MEILI_NO_ANALYTICS true RUN apk update --quiet \ && apk add -q --no-cache libgcc tini curl -# add meilisearch to the `/bin` so you can run it from anywhere and it's easy -# to find. -COPY --from=compiler /meilisearch/target/release/meilisearch /bin/meilisearch -# To stay compatible with the older version of the container (pre v0.27.0) we're -# going to symlink the meilisearch binary in the path to `/meilisearch` +COPY target/x86_64-unknown-linux-musl/release/meilisearch /bin/meilisearch RUN ln -s /bin/meilisearch /meilisearch -# This directory should hold all the data related to meilisearch so we're going -# to move our PWD in there. -# We don't want to put the meilisearch binary WORKDIR /meili_data - EXPOSE 7700/tcp ENTRYPOINT ["tini", "--"] diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index 6051b0cdd..934d91522 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -14,6 +14,26 @@ jobs: - name: checkout uses: actions/checkout@v3 + - run: sudo apt-get install musl-tools + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + target: x86_64-unknown-linux-musl + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2.2.0 + + - name: Run cargo check without any default features + uses: actions-rs/cargo@v1 + with: + command: build + args: --target x86_64-unknown-linux-musl --release + + - name: Remove dockerignore so we can use the target folder in our docker build + run: rm -f .dockerignore + - name: Set up QEMU uses: docker/setup-qemu-action@v2 diff --git a/.github/workflows/uffizzi-preview-deploy.yml b/.github/workflows/uffizzi-preview-deploy.yml index 8b3fdde96..fce60eb01 100644 --- a/.github/workflows/uffizzi-preview-deploy.yml +++ b/.github/workflows/uffizzi-preview-deploy.yml @@ -82,7 +82,7 @@ jobs: name: Use Remote Workflow to Preview on Uffizzi needs: - cache-compose-file - uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@desc + uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2 with: # If this workflow was triggered by a PR close event, cache-key will be an empty string # and this reusable workflow will delete the preview deployment. @@ -95,8 +95,8 @@ jobs: `meilisearch` command. You should be able to access this instance of meilisearch running in the preview from the link Meilisearch Endpoint link given below. - Web Terminal Endpoint : ${{ needs.cache-compose-file.outputs.expected-url }} - Meilisearch Endpoint : ${{ needs.cache-compose-file.outputs.expected-url }}/meilisearch + Web Terminal Endpoint : + Meilisearch Endpoint : /meilisearch permissions: contents: read pull-requests: write