Browse Source

Merge #717

717: Ci and docker improvement r=bonomat a=bonomat



Co-authored-by: bonomat <philipp@hoenisch.at>
debug-collab-settlement
bors[bot] 3 years ago
committed by GitHub
parent
commit
4dda5c695b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .cargo/config.toml
  2. 44
      .github/workflows/build-release-binary.yml
  3. 21
      .github/workflows/ci.yml
  4. 7
      .github/workflows/release-docker.yml
  5. 15
      Dockerfile
  6. 4
      bors.toml
  7. 2
      rust-toolchain.toml

2
.cargo/config.toml

@ -1,4 +1,2 @@
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.aarch64-unknown-linux-gnu] [target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc" linker = "aarch64-linux-gnu-gcc"

44
.github/workflows/build-release-binary.yml

@ -14,10 +14,6 @@ jobs:
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
- bin: taker
target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
archive_ext: tar
- bin: taker - bin: taker
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
@ -26,18 +22,10 @@ jobs:
target: x86_64-apple-darwin target: x86_64-apple-darwin
os: macos-latest os: macos-latest
archive_ext: tar archive_ext: tar
- bin: taker
target: x86_64-pc-windows-msvc
os: windows-latest
archive_ext: zip
- bin: maker - bin: maker
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
archive_ext: tar archive_ext: tar
- bin: maker
target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
archive_ext: tar
- bin: maker - bin: maker
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
os: ubuntu-latest os: ubuntu-latest
@ -46,10 +34,6 @@ jobs:
target: x86_64-apple-darwin target: x86_64-apple-darwin
os: macos-latest os: macos-latest
archive_ext: tar archive_ext: tar
- bin: maker
target: x86_64-pc-windows-msvc
os: windows-latest
archive_ext: zip
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout tagged commit - name: Checkout tagged commit
@ -65,12 +49,6 @@ jobs:
with: with:
key: ${{ matrix.target }} key: ${{ matrix.target }}
- name: Install compiler for armhf arch
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Install compiler for aarch64 arch (armv8) - name: Install compiler for aarch64 arch (armv8)
if: matrix.target == 'aarch64-unknown-linux-gnu' if: matrix.target == 'aarch64-unknown-linux-gnu'
run: | run: |
@ -95,8 +73,8 @@ jobs:
run: cargo build --target=${{ matrix.target }} --release --bin ${{ matrix.bin }} run: cargo build --target=${{ matrix.target }} --release --bin ${{ matrix.bin }}
- name: Smoke test the binary - name: Smoke test the binary
# armv7-* and aarch64-* is only cross-compiled, no smoke test # aarch64-* is only cross-compiled, no smoke test
if: matrix.target != 'armv7-unknown-linux-gnueabihf' && matrix.target != 'aarch64-unknown-linux-gnu' if: matrix.target != 'aarch64-unknown-linux-gnu'
run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help
# Remove once python 3 is the default # Remove once python 3 is the default
@ -105,7 +83,7 @@ jobs:
python-version: '3.x' python-version: '3.x'
- id: create-archive-name - id: create-archive-name
shell: python # Use python to have a prettier name for the archive on Windows. shell: python # Use python to have a prettier name for the archive.
run: | run: |
import platform import platform
os_info = platform.uname() os_info = platform.uname()
@ -129,13 +107,6 @@ jobs:
shell: bash shell: bash
run: tar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ matrix.bin }} run: tar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ matrix.bin }}
- name: Pack windows archive
if: matrix.os == 'windows-latest'
shell: bash
run: |
cp target/${{ matrix.target }}/release/${{ matrix.bin }}.exe ./${{ matrix.bin }}.exe
7z a -tzip ${{ steps.create-archive-name.outputs.archive }} ./${{ matrix.bin }}.exe
- name: Upload archive - name: Upload archive
uses: actions/upload-release-asset@v1.0.2 uses: actions/upload-release-asset@v1.0.2
env: env:
@ -181,7 +152,7 @@ jobs:
- name: Download release from github - name: Download release from github
run: | run: |
gh release download ${{ github.event.release.tag_name }} -p '${{matrix.bin}}*Linux_x86_64*' -p '${{matrix.bin}}*aarch64*' -p '${{matrix.bin}}*armv7*' gh release download ${{ github.event.release.tag_name }} -p '${{matrix.bin}}*Linux_x86_64*' -p '${{matrix.bin}}*aarch64*'
- name: Unpack archives - name: Unpack archives
run: | run: |
@ -189,13 +160,14 @@ jobs:
# #
# By providing `platform` to `docker buildx` the variable `TARGETPLATFORM` will be available # By providing `platform` to `docker buildx` the variable `TARGETPLATFORM` will be available
# when building the image. This variable is either # when building the image. This variable is either
# `linux/amd64/`, `linux/arm64/` or `linux/arm/v7`. Hence we need to extract into subfolders. # `linux/amd64/`, `linux/arm64/`. Hence we need to extract into subfolders.
7z x ${{matrix.bin}}_${{ github.event.release.tag_name }}_Linux_aarch64.tar -olinux/arm64/ 7z x ${{matrix.bin}}_${{ github.event.release.tag_name }}_Linux_aarch64.tar -olinux/arm64/
7z x ${{matrix.bin}}_${{ github.event.release.tag_name }}_Linux_x86_64.tar -olinux/amd64/ 7z x ${{matrix.bin}}_${{ github.event.release.tag_name }}_Linux_x86_64.tar -olinux/amd64/
7z x ${{matrix.bin}}_${{ github.event.release.tag_name }}_Linux_armv7.tar -olinux/arm/v7 chmod a+x linux/amd64/*
chmod a+x linux/arm64/*
- name: Build docker image for ${{matrix.bin}} - name: Build docker image for ${{matrix.bin}}
run: | run: |
@ -207,7 +179,7 @@ jobs:
docker buildx build \ docker buildx build \
--push \ --push \
--platform linux/amd64,linux/arm64,linux/arm/v7 \ --platform linux/amd64,linux/arm64 \
--label "org.opencontainers.image.source https://github.com/${{ github.repository }}" \ --label "org.opencontainers.image.source https://github.com/${{ github.repository }}" \
--tag ghcr.io/${{ github.repository }}/${{matrix.bin}}:${VERSION} \ --tag ghcr.io/${{ github.repository }}/${{matrix.bin}}:${VERSION} \
--build-arg BINARY_PATH=${{matrix.bin}} \ --build-arg BINARY_PATH=${{matrix.bin}} \

21
.github/workflows/ci.yml

@ -90,7 +90,7 @@ jobs:
test_daemons: test_daemons:
strategy: strategy:
matrix: matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ] os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2.4.0 - uses: actions/checkout@v2.4.0
@ -125,32 +125,21 @@ jobs:
daemons_arm_build: daemons_arm_build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: armv7-unknown-linux-gnueabihf
- target: aarch64-unknown-linux-gnu
steps: steps:
- uses: actions/checkout@v2.4.0 - uses: actions/checkout@v2.4.0
- name: Setup rust toolchain - name: Setup rust toolchain
run: rustup show run: rustup show
- uses: Swatinem/rust-cache@v1.3.0 - uses: Swatinem/rust-cache@v1.3.0
- name: Install compiler for armhf arch
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Install compiler for aarch64 arch - name: Install compiler for aarch64 arch
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu sudo apt-get install gcc-aarch64-linux-gnu
- run: cargo build --target=${{ matrix.target }} --bins - run: cargo build --target=aarch64-unknown-linux-gnu --bins
- name: Upload binaries - name: Upload binaries
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: maker-and-taker-binaries-${{ matrix.target }} name: maker-and-taker-binaries-aarch64-unknown-linux-gnu
path: | path: |
target/${{ matrix.target }}/debug/maker target/aarch64-unknown-linux-gnu/debug/maker
target/${{ matrix.target }}/debug/taker target/aarch64-unknown-linux-gnu/debug/taker

7
.github/workflows/release-docker.yml

@ -40,7 +40,7 @@ jobs:
- name: Download release - name: Download release
run: | run: |
gh release download ${{ github.event.inputs.release_tag }} -p '${{matrix.bin}}*Linux_x86_64*' -p '${{matrix.bin}}*aarch64*' -p '${{matrix.bin}}*armv7*' gh release download ${{ github.event.inputs.release_tag }} -p '${{matrix.bin}}*Linux_x86_64*' -p '${{matrix.bin}}*aarch64*'
- name: Unpack archives - name: Unpack archives
run: | run: |
@ -54,7 +54,8 @@ jobs:
7z x ${{matrix.bin}}_${{ github.event.inputs.release_tag }}_Linux_x86_64.tar -olinux/amd64/ 7z x ${{matrix.bin}}_${{ github.event.inputs.release_tag }}_Linux_x86_64.tar -olinux/amd64/
7z x ${{matrix.bin}}_${{ github.event.inputs.release_tag }}_Linux_armv7.tar -olinux/arm/v7 chmod a+x linux/amd64/*
chmod a+x linux/arm64/*
- name: Build docker image for ${{matrix.bin}} - name: Build docker image for ${{matrix.bin}}
run: | run: |
@ -66,7 +67,7 @@ jobs:
docker buildx build \ docker buildx build \
--push \ --push \
--platform linux/amd64,linux/arm64,linux/arm/v7 \ --platform linux/amd64,linux/arm64 \
--label "org.opencontainers.image.source https://github.com/${{ github.repository }}" \ --label "org.opencontainers.image.source https://github.com/${{ github.repository }}" \
--tag ghcr.io/${{ github.repository }}/${{matrix.bin}}:${VERSION} \ --tag ghcr.io/${{ github.repository }}/${{matrix.bin}}:${VERSION} \
--build-arg BINARY_PATH=${{matrix.bin}} \ --build-arg BINARY_PATH=${{matrix.bin}} \

15
Dockerfile

@ -1,19 +1,18 @@
FROM debian:bullseye-slim FROM gcr.io/distroless/cc
LABEL org.opencontainers.image.source https://github.com/itchysats/itchysats USER 1000
LABEL "org.opencontainers.image.source"="https://github.com/itchysats/itchysats"
LABEL "org.opencontainers.image.authors"="hello@itchysats.network"
ARG TARGETPLATFORM ARG TARGETPLATFORM
ARG BINARY_PATH ARG BINARY_PATH
RUN echo "Copying $TARGETPLATFORM/$BINARY_PATH into container" COPY $TARGETPLATFORM/$BINARY_PATH /usr/bin/binary
COPY $TARGETPLATFORM/$BINARY_PATH binary
RUN chmod a+x binary
VOLUME data VOLUME data
# HTTP Port and P2P Port # HTTP Port and P2P Port
EXPOSE 8000 9999 EXPOSE 8000 9999
ENTRYPOINT ["/binary", "--data-dir=/data", "--http-address=0.0.0.0:8000"] ENTRYPOINT ["/usr/bin/binary", "--data-dir=/data", "--http-address=0.0.0.0:8000"]

4
bors.toml

@ -6,7 +6,5 @@ status = [
"build_and_test_maker_frontend", "build_and_test_maker_frontend",
"test_daemons (ubuntu-latest)", "test_daemons (ubuntu-latest)",
"test_daemons (macos-latest)", "test_daemons (macos-latest)",
"test_daemons (windows-latest)", "daemons_arm_build",
"daemons_arm_build (armv7-unknown-linux-gnueabihf)",
"daemons_arm_build (aarch64-unknown-linux-gnu)",
] ]

2
rust-toolchain.toml

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "1.56" channel = "1.56"
components = ["clippy"] components = ["clippy"]
targets = ["armv7-unknown-linux-gnueabihf", "aarch64-unknown-linux-gnu"] targets = ["aarch64-unknown-linux-gnu"]

Loading…
Cancel
Save