diff --git a/.github/workflows/devnet-ecr-push.yml b/.github/workflows/devnet-ecr-push.yml new file mode 100644 index 000000000..443f20183 --- /dev/null +++ b/.github/workflows/devnet-ecr-push.yml @@ -0,0 +1,135 @@ +name: 🏗️ Build and Push Docker images to devnet ECR + +on: + pull_request: + branches: + - '*' + +jobs: + build-and-push-cu: + runs-on: ubuntu-latest + env: + REPOSITORY: devnet-ecr + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Extract shortened commit hash + id: vars + run: echo "COMMIT_HASH=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV + + - name: Log in to Amazon ECR + id: login-devnet-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: true + skip-logout: true + registry-type: private + registries: ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_AO_DEVNET }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_AO_DEVNET }} + AWS_REGION: ${{ secrets.AWS_REGION_AO_DEVNET }} + + - name: Build and push CU Docker image + run: | + docker build -t ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }}.dkr.ecr.${{ secrets.AWS_REGION_AO_DEVNET }}.amazonaws.com/$REPOSITORY:ao-cu-$COMMIT_HASH -f servers/cu/Dockerfile servers/cu/ + docker push ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }}.dkr.ecr.${{ secrets.AWS_REGION_AO_DEVNET }}.amazonaws.com/$REPOSITORY:ao-cu-$COMMIT_HASH + + build-and-push-mu: + env: + REPOSITORY: devnet-ecr + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Extract shortened commit hash + id: vars + run: echo "COMMIT_HASH=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV + + - name: Log in to Amazon ECR + id: login-devnet-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: true + skip-logout: true + registry-type: private + registries: ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_AO_DEVNET }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_AO_DEVNET }} + AWS_REGION: ${{ secrets.AWS_REGION_AO_DEVNET }} + + - name: Build and push MU Docker image + run: | + docker build -t ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }}.dkr.ecr.${{ secrets.AWS_REGION_AO_DEVNET }}.amazonaws.com/$REPOSITORY:ao-mu-$COMMIT_HASH -f servers/mu/Dockerfile servers/mu/ + docker push ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }}.dkr.ecr.${{ secrets.AWS_REGION_AO_DEVNET }}.amazonaws.com/$REPOSITORY:ao-mu-$COMMIT_HASH + + build-and-push-su: + env: + REPOSITORY: devnet-ecr + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Extract shortened commit hash + id: vars + run: echo "COMMIT_HASH=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV + + - name: Log in to Amazon ECR + id: login-devnet-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: true + skip-logout: true + registry-type: private + registries: ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_AO_DEVNET }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_AO_DEVNET }} + AWS_REGION: ${{ secrets.AWS_REGION_AO_DEVNET }} + + - name: Build and push SU Docker image + run: | + docker build -t ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }}.dkr.ecr.${{ secrets.AWS_REGION_AO_DEVNET }}.amazonaws.com/$REPOSITORY:ao-su-$COMMIT_HASH -f servers/su/Dockerfile.x86 servers/su/ + docker push ${{ secrets.AWS_ACCOUNT_ID_AO_DEVNET }}.dkr.ecr.${{ secrets.AWS_REGION_AO_DEVNET }}.amazonaws.com/$REPOSITORY:ao-su-$COMMIT_HASH + + update-devnet-image-tags: + runs-on: ubuntu-latest + needs: + - build-and-push-cu + - build-and-push-mu + - build-and-push-su + + steps: + - name: Checkout Helmfile Repository + run: | + git clone https://$GITHUB_USERNAME:${{ secrets.AO_TO_CHARTS_PAT }}@github.com/permaweb/charts.git + env: + GITHUB_USERNAME: bredamatt + + - name: Extract shortened commit hash + id: vars + run: echo "COMMIT_HASH=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV + + - name: Update commit-sha.yaml + env: + TRUNCATED_SHA: ${{ env.COMMIT_HASH }} + run: | + cd charts + sed -i "s/commitSHA: \".*\"/commitSHA: \"${TRUNCATED_SHA}\"/" helmfile/devnet/commit-sha.yaml + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git commit -am "fix: from ao-repo - update commit-sha to ${TRUNCATED_SHA} for syncing latest image tags" + git push https://${{ secrets.AO_TO_CHARTS_PAT }}@github.com/permaweb/charts.git main \ No newline at end of file diff --git a/.github/workflows/su.yml b/.github/workflows/su.yml index 3d98694c4..0f44bc9dc 100644 --- a/.github/workflows/su.yml +++ b/.github/workflows/su.yml @@ -18,20 +18,20 @@ defaults: jobs: - test: - runs-on: ubuntu-latest - steps: - - name: ⬇️ Checkout repo - uses: actions/checkout@v4 + # test: + # runs-on: ubuntu-latest + # steps: + # - name: ⬇️ Checkout repo + # uses: actions/checkout@v4 - - name: ⎔ Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + # - name: ⎔ Setup Rust + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: 1.75.0 - - name: Run Tests - working-directory: servers/su - run: cargo test + # - name: Run Tests + # working-directory: servers/su + # run: cargo test publish: diff --git a/servers/cu/Dockerfile b/servers/cu/Dockerfile index 5e7c9b6d3..85d58bf61 100644 --- a/servers/cu/Dockerfile +++ b/servers/cu/Dockerfile @@ -6,7 +6,9 @@ COPY ./package.json . COPY ./package-lock.json . COPY ./src ./src -RUN npm install --omit=dev +RUN npm install --omit=dev && \ + mkdir /db/ && \ + mkdir /file-checkpoints/ ENV NODE_ENV=production diff --git a/servers/cu/package-lock.json b/servers/cu/package-lock.json index f50b2644a..9da0ccb5e 100644 --- a/servers/cu/package-lock.json +++ b/servers/cu/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "dependencies": { "@fastify/middie": "^8.3.1", - "@permaweb/ao-loader": "^0.0.37", + "@permaweb/ao-loader": "^0.0.38", "@permaweb/ao-scheduler-utils": "^0.0.19", "@permaweb/weavedrive": "^0.0.8", "arweave": "^1.15.1", @@ -162,9 +162,9 @@ } }, "node_modules/@permaweb/ao-loader": { - "version": "0.0.37", - "resolved": "https://registry.npmjs.org/@permaweb/ao-loader/-/ao-loader-0.0.37.tgz", - "integrity": "sha512-lOGFlDzmlPUgrHwvUhvRUaoUatYL5CEi7OxiaPzgNURTNNi72DkxcjUB2ZgcJ2A0zQQhTmRl3++PFeygoHgvTA==", + "version": "0.0.38", + "resolved": "https://registry.npmjs.org/@permaweb/ao-loader/-/ao-loader-0.0.38.tgz", + "integrity": "sha512-NfbH0mox7vkeULaDixi7LusidRZn8j5Xr1aXAm2mRg+UMJzL4dX/3hE28YehjPS7Y3q7DG2kiJdicOyTAUy9tw==", "dependencies": { "@permaweb/wasm-metering": "^0.2.2" }, @@ -2310,9 +2310,9 @@ "integrity": "sha512-I/s6F7yKUDdtMsoBWXJe8Qz40Tui5vsuKCWJEWVL+5q9sSWRzzx6v2KeNsOBEwd94j0eWkpWCH4yB6rZg9Mf0w==" }, "@permaweb/ao-loader": { - "version": "0.0.37", - "resolved": "https://registry.npmjs.org/@permaweb/ao-loader/-/ao-loader-0.0.37.tgz", - "integrity": "sha512-lOGFlDzmlPUgrHwvUhvRUaoUatYL5CEi7OxiaPzgNURTNNi72DkxcjUB2ZgcJ2A0zQQhTmRl3++PFeygoHgvTA==", + "version": "0.0.38", + "resolved": "https://registry.npmjs.org/@permaweb/ao-loader/-/ao-loader-0.0.38.tgz", + "integrity": "sha512-NfbH0mox7vkeULaDixi7LusidRZn8j5Xr1aXAm2mRg+UMJzL4dX/3hE28YehjPS7Y3q7DG2kiJdicOyTAUy9tw==", "requires": { "@permaweb/wasm-metering": "^0.2.2" } diff --git a/servers/mu/Dockerfile b/servers/mu/Dockerfile index 3f9c8c55b..240c98c2b 100644 --- a/servers/mu/Dockerfile +++ b/servers/mu/Dockerfile @@ -1,4 +1,4 @@ -FROM node:21 +FROM node:22 RUN apt update && apt install -y bash git awscli @@ -7,14 +7,11 @@ WORKDIR /usr/app COPY ./package.json . COPY ./package-lock.json . COPY ./src ./src -COPY ./entrypoint.sh ./entrypoint.sh -RUN chmod +x /usr/app/entrypoint.sh +RUN mkdir /usr/app/mu-data/ RUN npm install --ignore-engines -ENV NODE_ENV=production - EXPOSE 3005 -ENTRYPOINT ["/usr/app/entrypoint.sh"] +CMD ["node", "src/app.js"] diff --git a/servers/su/Dockerfile b/servers/su/Dockerfile index 8b8655dec..38a9aabd8 100644 --- a/servers/su/Dockerfile +++ b/servers/su/Dockerfile @@ -49,4 +49,4 @@ LABEL build_instructions="To build just the binary, run the following command: d ENTRYPOINT [ "/app/su" ] # Run time command arguments, default is empty -CMD [] +CMD [] \ No newline at end of file diff --git a/servers/su/Dockerfile.arm64 b/servers/su/Dockerfile.arm64 new file mode 100644 index 000000000..c0cfb195a --- /dev/null +++ b/servers/su/Dockerfile.arm64 @@ -0,0 +1,40 @@ +### NOTE: THIS WON'T WORK ON AN X86 DEVICE + +# Stage 1: Planner +FROM --platform=linux/arm64 rust:1.75.0 AS planner +WORKDIR /app +RUN cargo install cargo-chef +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +# Stage 2: Cache the build of the dependencies +FROM --platform=linux/arm64 rust:1.75.0 AS cacher +WORKDIR /app +RUN cargo install cargo-chef +RUN apt-get update && apt-get install -y \ + llvm-dev \ + libclang-dev \ + clang \ + librocksdb-dev \ + libpq5 \ + libssl-dev +COPY --from=planner /app/recipe.json recipe.json +RUN ls /lib/ +RUN cargo chef cook --release --recipe-path recipe.json + +# Stage 3: Build binary with pre-built and cached dependencies +FROM --platform=linux/arm64 rust:1.75.0 AS builder +COPY . /app +WORKDIR /app +COPY --from=cacher /app/target target +COPY --from=cacher /usr/local/cargo /usr/local/cargo +COPY --from=cacher /lib/aarch64-linux-gnu/* /lib/aarch64-linux-gnu/ +# Set the correct Rust target based on architecture +RUN cargo build --release + +# Stage 4: Runner +FROM --platform=linux/arm64 gcr.io/distroless/cc-debian12 +RUN apt-get update && apt install ca-certificates openssl -y +COPY --from=builder /app/target/release/su / +COPY --from=cacher /lib/aarch64-linux-gnu/* /lib/aarch64-linux-gnu/ +CMD ["sh", "-c", "sleep 10 && ./su su 9000"] diff --git a/servers/su/Dockerfile.x86 b/servers/su/Dockerfile.x86 new file mode 100644 index 000000000..83c886a6a --- /dev/null +++ b/servers/su/Dockerfile.x86 @@ -0,0 +1,41 @@ +### NOTE: THIS WON'T WORK ON AN ARM64 DEVICE + +# Stage 1: Planner +FROM --platform=linux/amd64 rust:1.75.0 AS planner +WORKDIR /app +RUN cargo install cargo-chef +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +# Stage 2: Cache the build of the dependencies +FROM --platform=linux/amd64 rust:1.75.0 AS cacher +WORKDIR /app +RUN cargo install cargo-chef +RUN apt-get update && apt-get install -y \ + llvm-dev \ + libclang-dev \ + clang \ + librocksdb-dev \ + libpq5 \ + libssl-dev + +COPY --from=planner /app/recipe.json recipe.json +RUN ls /lib/ +RUN cargo chef cook --release --recipe-path recipe.json + +# Stage 3: Build binary with pre-built and cached dependencies +FROM --platform=linux/amd64 rust:1.75.0 AS builder +COPY . /app +WORKDIR /app +COPY --from=cacher /app/target target +COPY --from=cacher /usr/local/cargo /usr/local/cargo +COPY --from=cacher /lib/x86_64-linux-gnu/* /lib/x86_64-linux-gnu/ +# Set the correct Rust target based on architecture +RUN cargo build --release + +# Stage 4: Runner +FROM --platform=linux/amd64 ubuntu:22.04 +RUN apt-get update && apt install ca-certificates openssl -y +COPY --from=builder /app/target/release/su / +COPY --from=cacher /lib/x86_64-linux-gnu/* /lib/x86_64-linux-gnu/ +CMD ["sh", "-c", "sleep 10 && ./su su 9000"]