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

chore: add arm64 for raspi #9

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 17 additions & 2 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64

steps:
- uses: actions/checkout@v4
Expand All @@ -33,6 +39,11 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -46,13 +57,17 @@ jobs:
- name: Set up Docker image tag
run: echo "DOCKER_IMAGE_TAG=ghcr.io/$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')/${{ env.DOCKER-IMAGE }}:${{ env.DOCKER-TAG }}" >> $GITHUB_ENV

- name: Build and push
- name: Build and push Docker Image
uses: docker/build-push-action@v3
with:
context: ${{ env.DOCKER-CONTEXT }}
file: ${{ env.DOCKER-FILE }}
platforms: ${{ matrix.platform }}
tags: ${{ env.DOCKER_IMAGE_TAG }}
build-args: USERNAME=runner
build-args: |
USERNAME=runner
QEMU_CPU=cortex-a53
TARGETPLATFORM=${{ matrix.platform }}
ssh: default=${{ env.SSH_AUTH_SOCK }}
no-cache: true
push: false
19 changes: 17 additions & 2 deletions .github/workflows/push-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}

steps:
Expand All @@ -26,6 +32,11 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -39,13 +50,17 @@ jobs:
- name: Set up Docker image tag
run: echo "DOCKER_IMAGE_TAG=ghcr.io/$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')/${{ env.DOCKER-IMAGE }}:${{ env.DOCKER-TAG }}" >> $GITHUB_ENV

- name: Build and push
- name: Build and push Docker Image
uses: docker/build-push-action@v3
with:
context: ${{ env.DOCKER-CONTEXT }}
file: ${{ env.DOCKER-FILE }}
platforms: ${{ matrix.platform }}
tags: ${{ env.DOCKER_IMAGE_TAG }}
build-args: USERNAME=runner
build-args: |
USERNAME=runner
QEMU_CPU=cortex-a53
ssh: default=${{ env.SSH_AUTH_SOCK }}
no-cache: true
push: true

22 changes: 17 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM osrf/ros:humble-desktop-full
FROM osrf/ros:humble-desktop-full

SHELL ["/bin/bash", "-c"]

# 引数
ARG USERNAME="root"
ARG TARGETPLATFORM

# 環境変数の設定
ENV USER=$USERNAME \
Expand Down Expand Up @@ -36,10 +37,21 @@ USER $USERNAME
RUN mkdir -m 700 ~/.ssh && \
ssh-keyscan github.com > $HOME/.ssh/known_hosts

RUN --mount=type=ssh,uid=1000 source <(curl -s https://raw.githubusercontent.com/Shinsotsu-Tsukuba-Challenger/trainee/main/setup.sh) && \
: "remove cache" && \
sudo apt-get autoremove -y -qq && \
sudo rm -rf /var/lib/apt/lists/*
# アーキがamd64だったら実行
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
--mount=type=ssh,uid=1000 source <(curl -s https://raw.githubusercontent.com/Shinsotsu-Tsukuba-Challenger/trainee/main/setup.sh) pc && \
: "remove cache" && \
sudo apt-get autoremove -y -qq && \
sudo rm -rf /var/lib/apt/lists/*; \
fi

# アーキがarm64だったら実行
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
--mount=type=ssh,uid=1000 source <(curl -s https://raw.githubusercontent.com/Shinsotsu-Tsukuba-Challenger/trainee/main/setup.sh) raspi && \
: "remove cache" && \
sudo apt-get autoremove -y -qq && \
sudo rm -rf /var/lib/apt/lists/*; \
fi

# 設定の書き込み
RUN echo "source /etc/bash_completion" >> $HOME/.bashrc && \
Expand Down
Loading