diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 94d1f9ee0..09f1e8616 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,9 @@ on: push: jobs: - engine: + mono: 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 @@ -76,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/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' }} + 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/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"]