diff --git a/.github/workflows/cross-compiling-docker.yml b/.github/workflows/cross-compiling-docker.yml index 42de6f7c6..cab9ac403 100644 --- a/.github/workflows/cross-compiling-docker.yml +++ b/.github/workflows/cross-compiling-docker.yml @@ -20,3 +20,35 @@ jobs: run: echo "CC=$(./.github/workflows/get-compiler.sh ccomp)" >> $GITHUB_ENV # https://stackoverflow.com/a/57969570/3551604 - run: go env - run: ./build.sh + - name: upload build artifacts + uses: actions/upload-artifact@v2 + with: + name: bin-${{ matrix.target }} + path: ./bin + build-monolith: + strategy: + matrix: + target: [amd64, arm64, arm] + env: + DOCKER_HUB_USER: dendritegithub + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: bin-${{ matrix.target }} + # - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - run: echo "DOCKER_TARGET=$(./.github/workflows/get-compiler.sh docker)" >> $GITHUB_ENV + # For building docker images, QEMU and buildx is still easier than anything to do with docker manifest editing + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/docker/Dockerfile.monolith + platforms: ${{ env.PLATFORMS }} + push: false + tags: | + ${{ env.DOCKER_NAMESPACE }}/dendrite-monolith:latest diff --git a/.github/workflows/get-compiler.sh b/.github/workflows/get-compiler.sh index cbfb75457..8494517fd 100755 --- a/.github/workflows/get-compiler.sh +++ b/.github/workflows/get-compiler.sh @@ -1,6 +1,24 @@ #!/bin/bash set -eu +# Given a GOARCH target, return what Docker calls that target. +function get_docker() { + case "$GOARCH" in + "amd64") + echo "linux/amd64" + ;; + "arm64") + echo "linux/arm64/v8" + ;; + "arm") + echo "linux/arm/v7" + ;; + *) + exit 1 + ;; + esac +} + # Given a GOARCH target, return the GCC for that target. function get_compiler() { case "$GOARCH" in @@ -41,6 +59,9 @@ case "$1" in "ccomp") get_compiler ;; +"docker") + get_docker + ;; *) exit 1 ;; diff --git a/build.sh b/build.sh index 3a2053a0e..a49814084 100755 --- a/build.sh +++ b/build.sh @@ -21,4 +21,4 @@ mkdir -p bin CGO_ENABLED=1 go build -trimpath -ldflags "$FLAGS" -v -o "bin/" ./cmd/... -CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -ldflags "$FLAGS" -o bin/main.wasm ./cmd/dendritejs \ No newline at end of file +CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -ldflags "$FLAGS" -o bin/main.wasm ./cmd/dendritejs