diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bc9be8..356f38a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: Node.js CI on: push: - branches: [main] + branches: [chromium-patch-1, main] pull_request: branches: [main] env: @@ -10,8 +10,65 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-and-push-image: - runs-on: ubuntu-latest + + build_arms: + + runs-on: ubuntu-20.04 + name: Build on ${{ matrix.distro }} ${{ matrix.arch }} + + strategy: + matrix: + include: + - arch: aarch64 + distro: ubuntu20.04 + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - uses: uraimo/run-on-arch-action@v2 + name: Build artifact + id: build + with: + arch: ${{ matrix.arch }} + distro: ${{ matrix.distro }} + githubToken: ${{ github.token }} + run: | + uname -a + # echo ::set-output name=uname::$(uname -a) + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + build: + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest] permissions: contents: read packages: write @@ -20,6 +77,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + # - name: Display current branch + # run: echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" + - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: @@ -37,6 +97,6 @@ jobs: uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: context: . - push: true + push: false tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index c976e1a..1ca766b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,34 @@ FROM node:19 WORKDIR /app +ARG TARGETPLATFORM + +RUN echo "Building for $TARGETPLATFORM" + +COPY debian-stable.list /tmp + # We don't need the standalone Chromium -RUN apt-get install -y wget \ - && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ - && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \ - && apt-get update && apt-get -y install google-chrome-stable chromium xvfb\ - && rm -rf /var/lib/apt/lists/* \ - && echo "Chrome: " && google-chrome --version +RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + apt-get install -y wget curl gnupg \ + && cp /tmp/debian-stable.list /etc/apt/sources.list.d/ \ + && apt-get update && apt-get -y install chromium xvfb \ + && echo "Chrome: " && chromium --version \ + && ln -s /usr/bin/chromium /usr/bin/google-chrome-stable \ + else \ + apt-get install -y wget \ + && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \ + && apt-get update && apt-get -y install google-chrome-stable chromium xvfb\ + && echo "Chrome: " && google-chrome --version ; \ + fi + +# Remove tmp file +RUN rm -rf /var/lib/apt/lists/* +RUN rm -rf /tmp/debian-stable.list + COPY package.json . COPY package-lock.json . RUN npm install COPY . . RUN npm run build EXPOSE 4000 -CMD npx prisma migrate deploy && xvfb-run --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR -maxclients 2048" node dist/index.js \ No newline at end of file +CMD npx prisma migrate deploy && xvfb-run --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR -maxclients 2048" node dist/index.js diff --git a/debian-stable.list b/debian-stable.list new file mode 100644 index 0000000..ffb5482 --- /dev/null +++ b/debian-stable.list @@ -0,0 +1,8 @@ +deb [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian stable main +deb-src [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian stable main + +deb [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian-security/ stable-security main +deb-src [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian-security/ stable-security main + +deb [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian stable-updates main +deb-src [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian stable-updates main