From e8ff66053276f86b45fd381ec65bf3df14a557af Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Mon, 2 Oct 2023 19:27:44 +0900 Subject: [PATCH] Add: Add Dockerfile --- .github/workflows/sub-image-check.yml | 47 ++++++++++++++------------- sub-image/Dockerfile | 6 ++++ 2 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 sub-image/Dockerfile diff --git a/.github/workflows/sub-image-check.yml b/.github/workflows/sub-image-check.yml index 28a378e..3787182 100644 --- a/.github/workflows/sub-image-check.yml +++ b/.github/workflows/sub-image-check.yml @@ -10,35 +10,36 @@ on: jobs: lint: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./sub-image steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup python - uses: actions/setup-python@v4 - with: - python-version-file: sub-image/.python-version - - name: Install poetry - uses: Gr1N/setup-poetry@v8 - with: - poetry-version: 1.3.1 - - name: Config poetry - run: poetry config virtualenvs.create false - - name: Cache venv - uses: actions/cache@v3 - with: - path: .venv - key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} - restore-keys: | - ${{ runner.os }}-poetry- - - name: Install dependencies - working-directory: ./sub-image - run: poetry install + - name: Setup rust + run: | + rustup toolchain install + rustup target add aarch64-unknown-linux-gnu + - name: Cache target + uses: Swatinem/rust-cache@v2 + - name: Run check + run: | + cargo clippy + cargo fmt -- --check + cargo test - - name: Run sub-image lint - working-directory: ./sub-image + - name: Build binary + if: github.ref_name == 'main' + working-directory: . run: | - poetry run poe lint + cargo build --release --target x86_64-unknown-linux-gnu + cargo build --release --target aarch64-unknown-linux-gnu + + mkdir /tmp/sub-image/arm64 -p + mkdir /tmp/sub-image/amd64 -p + cp target/x86_64-unknown-linux-gnu/release/sub-image /tmp/sub-image/amd64/sub-image + cp target/aarch64-unknown-linux-gnu/release/sub-image /tmp/sub-image/arm64/sub-image - name: Build image if: github.ref_name == 'main' uses: ./.github/actions/build diff --git a/sub-image/Dockerfile b/sub-image/Dockerfile new file mode 100644 index 0000000..677c955 --- /dev/null +++ b/sub-image/Dockerfile @@ -0,0 +1,6 @@ +FROM ubuntu:22.04 +ARG TARGETARCH +COPY /tmp/sub-image/${TARGETARCH}/sub-image /app/sub-image + +WORKDIR /app +ENTRYPOINT ["/app/sub-image"]