Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/fix-image-pipelines #1033

Merged
merged 35 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9269dae
feat: add initial dockerfile
bredamatt Sep 30, 2024
f2b8cc1
Merge branch 'main' of github.com:permaweb/ao into feat/fix-image-pip…
bredamatt Sep 30, 2024
1b3314e
fix: Add arch specific images due to dynamic linking
bredamatt Sep 30, 2024
9abd962
fix: Change runner image to ubuntu:22.04
bredamatt Sep 30, 2024
bc654ac
fix: Adjust path for libc deps
bredamatt Sep 30, 2024
e72dfdc
fix: Update arm64 Dockerfile paths for aarch64-linux-gnu
bredamatt Sep 30, 2024
191e043
fix: add missing / to lib paths
bredamatt Sep 30, 2024
44079cd
fix: remove target during build
bredamatt Sep 30, 2024
4ef0c74
fix: libpq5 in stead of libpq-dev
bredamatt Sep 30, 2024
f96d040
fix: specify platform in dockerfiles
bredamatt Sep 30, 2024
e48ca07
fix: correct CMD for su image
bredamatt Sep 30, 2024
ec8c57f
fix: make sure runner image has openssl and ca-certificates and sleep…
bredamatt Oct 3, 2024
5d1612f
fix: add directories to cu
bredamatt Oct 9, 2024
dbb1782
fix: add prototype (unfiinished) github action
bredamatt Oct 10, 2024
222f9a8
fix: add mu Dockerfile that works in k8s
bredamatt Oct 10, 2024
9958e50
fix: add workflow
bredamatt Oct 11, 2024
d917f69
Merge branch 'main' of github.com:permaweb/ao into feat/fix-image-pip…
bredamatt Oct 11, 2024
d338769
fix: only trigger on PRs in servers/*
bredamatt Oct 11, 2024
681135b
fix: remove redundant workflow
bredamatt Oct 11, 2024
abeae97
fix: update workflow name
bredamatt Oct 11, 2024
62d2326
fix: test login once and use outputs
bredamatt Oct 11, 2024
44d7547
fix: trigger on change to workflow
bredamatt Oct 11, 2024
ccb8119
fix: trigger on all changes
bredamatt Oct 11, 2024
405f7df
Revert "fix: remove redundant workflow"
bredamatt Oct 11, 2024
0db60d2
revert: go back to working
bredamatt Oct 11, 2024
02d887c
fix: see if only account ID is necessary
bredamatt Oct 11, 2024
dd3a1ca
fix: delete unnecessary pipeline
bredamatt Oct 14, 2024
a8b9f74
fix: add automatic commit to charts repo to update commi
bredamatt Oct 14, 2024
35c3c6d
fix: typos in action
bredamatt Oct 14, 2024
8da05fc
fix: try with username
bredamatt Oct 14, 2024
7da2b17
fix: typo in push command
bredamatt Oct 14, 2024
7022e69
fix: make sure commit sha is extracted in update-devnet-image-tags
bredamatt Oct 14, 2024
5a2b095
Merge branch 'main' of github.com:permaweb/ao into feat/fix-image-pip…
bredamatt Oct 14, 2024
9abc184
chore(su): add back in dockerfile and fix test toolchain
VinceJuliano Oct 14, 2024
8a7a671
chore(su): remove rust tests from yml
VinceJuliano Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions .github/workflows/devnet-ecr-push.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions .github/workflows/su.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion servers/cu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions servers/cu/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions servers/mu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:21
FROM node:22

RUN apt update && apt install -y bash git awscli

Expand All @@ -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"]
2 changes: 1 addition & 1 deletion servers/su/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
40 changes: 40 additions & 0 deletions servers/su/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -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"]
41 changes: 41 additions & 0 deletions servers/su/Dockerfile.x86
Original file line number Diff line number Diff line change
@@ -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"]
Loading