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

use arm runner #2483

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
74 changes: 47 additions & 27 deletions .github/workflows/build-branch.yml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
string should not be empty [syntax-check]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
property "meta" is not defined in object type {buildx: {conclusion: string; outcome: string; outputs: {driver: string; endpoint: string; flags: string; name: string; nodes: string; platforms: string; status: string}}; login-ecr: {conclusion: string; outcome: string; outputs: {string => string}}; tags: {conclusion: string; outcome: string; outputs: {string => string}}} [expression]

labels: ${{ steps.meta.outputs.labels }}

Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,22 @@ jobs:
strategy:
matrix:
runs-on:
- "ubuntu-latest"
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
if: github.event.pusher.name != 'dreamkast-cloudnativedays'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
id: buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Login to Amazon ECR
- uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs
tags: |
type=sha,prefix=,format=long
type=ref,event=branch

- name: Prepare-tag
id: tags
run: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:7:41: Double quote to prevent globbing and word splitting [shellcheck]

Expand All @@ -51,13 +35,13 @@ jobs:
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${{ github.sha }}-${arch}" >> $GITHUB_OUTPUT

- name: Build
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ steps.tags.outputs.tag }}
provenance: false
Expand All @@ -66,10 +50,33 @@ jobs:
cache-to: type=gha,mode=max

merge-images:
runs-on: "ubuntu-latest"
strategy:
matrix:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
needs: ["build"]
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs
tags: |
type=sha,prefix=,format=long
type=ref,event=branch
- name: Prepare-tag
id: tags
run: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:7:23: Double quote to prevent globbing and word splitting [shellcheck]

arch=""
# https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
case "${{ runner.arch }}" in
"X64" ) arch="amd64" ;;
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${arch}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -87,9 +94,22 @@ jobs:
- name: Create a New Image
run: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1073:error:5:1: Couldn't parse this for loop. Fix to allow more checks [shellcheck]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1061:error:5:26: Couldn't find 'done' for this 'do' [shellcheck]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1062:error:14:1: Expected 'done' matching previously mentioned 'do' [shellcheck]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1072:error:14:1: Expected 'done'. Fix any mentioned problems and try again [shellcheck]

image_tag_sha="${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ github.sha }}"
docker buildx imagetools create \
--tag ${image_tag_sha} \
${image_tag_sha}-amd64

# Create array of image tags from meta output
image_tags=()
for tag in ${{ steps.meta.outputs.tags }}; do
image_tags+=("${tag}-${{ steps.tags.outputs.tag }}")
done

# Join all tags with comma for buildx imagetools create command
joined_tags=$(IFS=,; echo "${image_tags[*]}")

# Create manifest lists for each tag from meta output
for tag in ${{ steps.meta.outputs.tags }}; do
docker buildx imagetools create \
--tag ${tag} \
${image_tag_sha}-${{ steps.tags.outputs.tag }}


# - name: Run Trivy vulnerability scanner
# uses: aquasecurity/trivy-action@master
Expand Down
104 changes: 83 additions & 21 deletions .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
id: buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-1

- name: Login to Amazon ECR
- uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs
tags: |
type=sha,prefix=,format=long
type=ref,event=tag

- name: Prepare-tag
id: tags
run: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:7:41: Double quote to prevent globbing and word splitting [shellcheck]

arch=""
# https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
case "${{ runner.arch }}" in
"X64" ) arch="amd64" ;;
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${{ github.sha }}-${arch}" >> $GITHUB_OUTPUT
- name: Build
id: docker_build
uses: docker/build-push-action@v6
Expand All @@ -42,7 +42,69 @@ jobs:
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ steps.tags.outputs.tag }}
provenance: false
labels: ${{ steps.meta.outputs.labels }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
property "meta" is not defined in object type {buildx: {conclusion: string; outcome: string; outputs: {driver: string; endpoint: string; flags: string; name: string; nodes: string; platforms: string; status: string}}; login-ecr: {conclusion: string; outcome: string; outputs: {string => string}}; tags: {conclusion: string; outcome: string; outputs: {string => string}}} [expression]

cache-from: type=gha
cache-to: type=gha,mode=max

merge-images:
strategy:
matrix:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
needs: ["build"]
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
property "login-ecr" is not defined in object type {} [expression]

tags: |
type=sha,prefix=,format=long
type=ref,event=tag
- name: Prepare-tag
id: tags
run: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:7:23: Double quote to prevent globbing and word splitting [shellcheck]

arch=""
# https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
case "${{ runner.arch }}" in
"X64" ) arch="amd64" ;;
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${arch}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Create a New Image
run: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1073:error:13:1: Couldn't parse this for loop. Fix to allow more checks [shellcheck]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1061:error:13:44: Couldn't find 'done' for this 'do' [shellcheck]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1062:error:17:1: Expected 'done' matching previously mentioned 'do' [shellcheck]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC1072:error:17:1: Expected 'done'. Fix any mentioned problems and try again [shellcheck]

image_tag_sha="${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ github.sha }}"

# Create array of image tags from meta output
image_tags=()
for tag in ${{ steps.meta.outputs.tags }}; do
image_tags+=("${tag}-${{ steps.tags.outputs.tag }}")
done

# Join all tags with comma for buildx imagetools create command
joined_tags=$(IFS=,; echo "${image_tags[*]}")

# Create manifest lists for each tag from meta output
for tag in ${{ steps.meta.outputs.tags }}; do
docker buildx imagetools create \
--tag ${tag} \
${image_tag_sha}-${{ steps.tags.outputs.tag }}
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
COPY --link --from=node /app/node_modules /app/node_modules
COPY --link --from=fetch-lib /usr/local/bundle /usr/local/bundle
RUN apt-get update && apt-get install -y libvips42
ENV AWS_ACCESS_KEY_ID=''

Check warning on line 34 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "AWS_ACCESS_KEY_ID") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 34 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04-arm)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "AWS_ACCESS_KEY_ID") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ARG RAILS_ENV='production'
RUN --mount=type=cache,uid=1000,target=/app/tmp/cache SECRET_KEY_BASE=hoge RAILS_ENV=${RAILS_ENV} DB_ADAPTER=nulldb bin/rails assets:precompile

Expand All @@ -47,10 +47,10 @@
WORKDIR /app
COPY --link --from=node /app/node_modules /app/node_modules
COPY --link --from=fetch-lib /usr/local/bundle /usr/local/bundle
RUN apt-get update && apt-get -y install wget libmariadb3 libvips42 \
&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt install -y ./google-chrome-stable_current_amd64.deb \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get -y install wget libmariadb3 libvips42 chromium && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV CHROME_BIN=/usr/bin/chromium
COPY --link . .
COPY --link --from=asset-compile /app/public /app/public
EXPOSE 3000
Expand Down
Loading