From 99d68ca3e48a1e79ac383c259ec579f737da9ec2 Mon Sep 17 00:00:00 2001 From: Eli Ma Date: Tue, 10 Dec 2024 11:31:39 +0800 Subject: [PATCH 1/4] Add namespace condition in GitHub Action Signed-off-by: Eli Ma --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 94d1f9ee0..519136af0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ on: jobs: engine: runs-on: ubuntu-latest + if: github.repository_owner == 'genedna' steps: - name: Log in to Docker Hub uses: docker/login-action@v3 @@ -30,6 +31,7 @@ jobs: outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} postgres: runs-on: ubuntu-latest + if: github.repository_owner == 'genedna' steps: - name: Log in to Docker Hub uses: docker/login-action@v3 @@ -54,6 +56,7 @@ jobs: outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} ui: runs-on: ubuntu-latest + if: github.repository_owner == 'genedna' steps: - name: Log in to Docker Hub uses: docker/login-action@v3 From 8558c6c5a88de58c5be41981ca9d0960d5e277ac Mon Sep 17 00:00:00 2001 From: Eli Ma Date: Tue, 10 Dec 2024 11:42:19 +0800 Subject: [PATCH 2/4] Add aries and mega build in Docker Cloud Build Signed-off-by: Eli Ma --- .github/workflows/build.yml | 52 ++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 519136af0..e6dcccd29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: jobs: - engine: + mono: runs-on: ubuntu-latest if: github.repository_owner == 'genedna' steps: @@ -79,3 +79,53 @@ jobs: # For pull requests, export results to the build cache. # Otherwise, push to a registry. outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} + aries: + runs-on: ubuntu-latest + if: github.repository_owner == 'genedna' + steps: + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_PAT }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + version: "lab:latest" + driver: cloud + endpoint: "${{ vars.DOCKER_USER }}/mono" + platforms: linux/amd64,linux/arm64 + install: true + - name: Build and push + uses: docker/build-push-action@v6 + with: + tags: "${{ vars.DOCKER_USER }}/mono:aries-engine-latest" + file: docker/docker/aries-engine-dockerfile + # For pull requests, export results to the build cache. + # Otherwise, push to a registry. + outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} + mega: + runs-on: ubuntu-latest + if: github.repository_owner == 'genedna' + steps: + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_PAT }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + version: "lab:latest" + driver: cloud + endpoint: "${{ vars.DOCKER_USER }}/mono" + platforms: linux/amd64,linux/arm64 + install: true + - name: Build and push + uses: docker/build-push-action@v6 + with: + tags: "${{ vars.DOCKER_USER }}/mono:mega-engine-latest" + file: docker/docker/mega-engine-dockerfile + # For pull requests, export results to the build cache. + # Otherwise, push to a registry. + outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} From 6ef34c2efad3962485940a25956dc0664a60035b Mon Sep 17 00:00:00 2001 From: Eli Ma Date: Tue, 10 Dec 2024 11:45:14 +0800 Subject: [PATCH 3/4] Fix Dockerfile path error Signed-off-by: Eli Ma --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6dcccd29..6d61d197e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,7 +100,7 @@ jobs: uses: docker/build-push-action@v6 with: tags: "${{ vars.DOCKER_USER }}/mono:aries-engine-latest" - file: docker/docker/aries-engine-dockerfile + file: docker/aries-engine-dockerfile # For pull requests, export results to the build cache. # Otherwise, push to a registry. outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} @@ -125,7 +125,7 @@ jobs: uses: docker/build-push-action@v6 with: tags: "${{ vars.DOCKER_USER }}/mono:mega-engine-latest" - file: docker/docker/mega-engine-dockerfile + file: docker/mega-engine-dockerfile # For pull requests, export results to the build cache. # Otherwise, push to a registry. outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} From 5e344584ab9b8e7149bc21800638a40482d9ba9a Mon Sep 17 00:00:00 2001 From: Eli Ma Date: Wed, 11 Dec 2024 15:17:57 +0800 Subject: [PATCH 4/4] Add aries-engine and mega-engine Dockerfile for build image Signed-off-by: Eli Ma --- .github/workflows/build.yml | 4 +- docker/aries-engine-dockerfile-hub | 68 +++++++++++++++++++++++++++++ docker/mega-engine-dockerfile-hub | 69 ++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 docker/aries-engine-dockerfile-hub create mode 100644 docker/mega-engine-dockerfile-hub diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d61d197e..09f1e8616 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,7 +100,7 @@ jobs: uses: docker/build-push-action@v6 with: tags: "${{ vars.DOCKER_USER }}/mono:aries-engine-latest" - file: docker/aries-engine-dockerfile + file: docker/aries-engine-dockerfile-hub # For pull requests, export results to the build cache. # Otherwise, push to a registry. outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} @@ -125,7 +125,7 @@ jobs: uses: docker/build-push-action@v6 with: tags: "${{ vars.DOCKER_USER }}/mono:mega-engine-latest" - file: docker/mega-engine-dockerfile + file: docker/mega-engine-dockerfile-hub # For pull requests, export results to the build cache. # Otherwise, push to a registry. outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }} diff --git a/docker/aries-engine-dockerfile-hub b/docker/aries-engine-dockerfile-hub new file mode 100644 index 000000000..6e4997b26 --- /dev/null +++ b/docker/aries-engine-dockerfile-hub @@ -0,0 +1,68 @@ +FROM debian:bookworm-slim AS builder + +WORKDIR /opt/mega + +# build args, to specify the build type, release or debug +ARG BUILD_TYPE=release + +# check arg value +RUN if [ "$BUILD_TYPE" != "release" ] && [ "$BUILD_TYPE" != "debug" ]; then \ + echo "Invalid BUILD_TYPE: $BUILD_TYPE, must be release or debug"; \ + exit 1; \ + fi + +# set mirror for apt +# RUN echo "deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free" > /etc/apt/sources.list && \ +# echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free" >> /etc/apt/sources.list && \ +# echo "deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free" >> /etc/apt/sources.list + +RUN apt-get update && apt-get install -y \ + cmake \ + clang \ + build-essential \ + nodejs \ + npm \ + curl \ + wget \ + file \ + libssl-dev \ + libgtk-3-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + ca-certificates \ + && curl https://sh.rustup.rs -sSf | sh -s -- -y \ + && . $HOME/.cargo/env + +ENV PATH=/root/.cargo/bin:$PATH + +# clone the source code, the context must be the root of the project +RUN git clone https://github.com/genedna/mega.git . + +# build +RUN cargo clean +RUN git submodule deinit --all -f +RUN git submodule update --init --recursive +RUN if [ "$BUILD_TYPE" = "release" ]; then \ + cargo build -p aries --release; \ + else \ + cargo build -p aries; \ + fi + +# final image +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y libssl-dev ca-certificates + +ARG BUILD_TYPE=release + +COPY --from=builder /opt/mega/target/$BUILD_TYPE/aries /usr/local/bin/aries +COPY --from=builder /opt/mega/docker/start-aries.sh /usr/local/bin/start-aries.sh +RUN chmod +x /usr/local/bin/start-aries.sh +RUN chmod +x /usr/local/bin/aries +COPY --from=builder /opt/mega/target/$BUILD_TYPE/libpipy.so /usr/local/lib/libpipy.so +# refresh shared library cache +RUN ldconfig + +VOLUME /opt/mega + +CMD ["bash", "-c", "/usr/local/bin/start-aries.sh"] diff --git a/docker/mega-engine-dockerfile-hub b/docker/mega-engine-dockerfile-hub new file mode 100644 index 000000000..12d445f4a --- /dev/null +++ b/docker/mega-engine-dockerfile-hub @@ -0,0 +1,69 @@ +FROM debian:bookworm-slim AS builder + +WORKDIR /opt/mega + +# build args, to specify the build type, release or debug +ARG BUILD_TYPE=release + +# check arg value +RUN if [ "$BUILD_TYPE" != "release" ] && [ "$BUILD_TYPE" != "debug" ]; then \ + echo "Invalid BUILD_TYPE: $BUILD_TYPE, must be release or debug"; \ + exit 1; \ + fi + +# set mirror for apt +# RUN echo "deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free" > /etc/apt/sources.list && \ +# echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free" >> /etc/apt/sources.list && \ +# echo "deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free" >> /etc/apt/sources.list + +RUN apt-get update && apt-get install -y \ + cmake \ + clang \ + build-essential \ + nodejs \ + npm \ + curl \ + wget \ + file \ + libssl-dev \ + libgtk-3-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + ca-certificates \ + && curl https://sh.rustup.rs -sSf | sh -s -- -y \ + && . $HOME/.cargo/env + +ENV PATH=/root/.cargo/bin:$PATH + +# clone the source code, the context must be the root of the project +RUN git clone https://github.com/genedna/mega.git . + + +# build +RUN cargo clean +RUN git submodule deinit --all -f +RUN git submodule update --init --recursive +RUN if [ "$BUILD_TYPE" = "release" ]; then \ + cargo build -p mega --release; \ + else \ + cargo build -p mega; \ + fi + +# final image +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y libssl-dev ca-certificates + +ARG BUILD_TYPE=release + +COPY --from=builder /opt/mega/target/$BUILD_TYPE/mega /usr/local/bin/mega +COPY --from=builder /opt/mega/docker/start-mega.sh /usr/local/bin/start-mega.sh +RUN chmod +x /usr/local/bin/start-mega.sh +RUN chmod +x /usr/local/bin/mega +COPY --from=builder /opt/mega/target/$BUILD_TYPE/libpipy.so /usr/local/lib/libpipy.so +# refresh shared library cache +RUN ldconfig + +VOLUME /opt/mega + +CMD ["bash", "-c", "/usr/local/bin/start-mega.sh"]