From 46250aeb0aac43e5d9c45c491e0ad975b2be841c Mon Sep 17 00:00:00 2001 From: Filius Patris Date: Mon, 3 Aug 2020 09:35:03 +0200 Subject: [PATCH] Target multiple architectures (follow-up to #28) (#31) * Revert and fix commit 3198879 Commit 3198879 prepended the CYPRESS_INSTALL_BINARY=0 variable to the install command in the ressources/assets directory, however this component does not require cypress. The root component however does. This environment variable should be prepended to the second install command. * Add 'install buildx' step This is just blindly following this blogpost: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/ * Target multiple architectures See this blogpost for more on how this works: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/ * Add python2 dependency to front-builder This error message shows it: https://github.com/Filius-Patris/docker-koel/runs/915997770?check_suite_focus=true#step:5:8914 This issue comment suggests why: https://github.com/sass/node-sass/issues/1176#issuecomment-323035618 TL;DR: Building some component requires python. This would normally be precompiled and fetched, but arm doesn't have precompiled packages. * Increase network timeout The CICD errors seems to be tied to this: https://github.com/yarnpkg/yarn/issues/4890#issuecomment-348479446 * Try building the 3 architectures at the end of the CI. This is meant to test the CI. If it works, it will be done in publish.yml instead of dockerimage.yml. * Update CI/CD pipelines For more details, see the discussions on PR #31. With this commit, some targets in the Makefile are unneeded, but I left them anyway. * Correcting the tags: argument I wasn't understanding the docs correctly. * Refine CI/CD pipelines more With this commit the pipeline completely cut reliance to the Makefile. This helps to make everything more obvious by only looking at the pipeline yaml file. Co-authored-by: Joris MASSON --- .github/workflows/dockerimage.yml | 20 ----------------- .github/workflows/publish.yml | 24 --------------------- .github/workflows/test-and-deploy.yml | 31 +++++++++++++++++++++++++++ .github/workflows/test.yml | 24 +++++++++++++++++++++ Dockerfile | 4 ++-- Makefile | 5 ++++- 6 files changed, 61 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/dockerimage.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test-and-deploy.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index b95dbaa..0000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,20 +0,0 @@ - -name: Docker Image CI -on: - pull_request: - push: - branches-ignore: [master] -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Install goss and dgoss - uses: e1himself/goss-installation-action@v1 - with: - # Goss release version to install - version: 'v0.3.13' - - uses: actions/checkout@v2 - - name: Build the Docker image - run: make build-docker-image - - name: Run goss tests - run: make dgoss-ci diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index d904172..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Docker Hub publish -on: - push: - branches: [master] -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Install goss and dgoss - uses: e1himself/goss-installation-action@v1 - with: - # Goss release version to install - version: 'v0.3.11' - - uses: actions/checkout@v2 - - name: Build the Docker image - run: make build-docker-image - - name: Run goss tests - run: dgoss run hyzual/koel-dev:latest - - name: make dgoss-ci - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: hyzual/koel - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml new file mode 100644 index 0000000..cd3abce --- /dev/null +++ b/.github/workflows/test-and-deploy.yml @@ -0,0 +1,31 @@ +name: Run tests and deploy image +on: + push: + branches: [master] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Install goss and dgoss + uses: e1himself/goss-installation-action@v1 + with: + # Goss release version to install + version: "v0.3.13" + - name: Checkout code + uses: actions/checkout@v2 + - name: Build the x86_64 Docker image + uses: docker/build-push-action@v1.1.0 + with: + push: false + repository: hyzual/koel + tags: latest + - name: Run goss tests on x86_64 image + run: dgoss run hyzual/koel:latest + - name: Build and push production image + uses: zmingxie/docker_buildx@v1.1 + with: + publish: true + imageName: hyzual/koel + tag: latest + dockerHubUser: ${{ secrets.DOCKER_HUB_USERNAME }} + dockerHubPassword: ${{ secrets.DOCKER_HUB_PASSWORD }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..131a960 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: Run tests +on: + pull_request: + push: + branches-ignore: [master] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Install goss and dgoss + uses: e1himself/goss-installation-action@v1 + with: + # Goss release version to install + version: "v0.3.13" + - name: Checkout code + uses: actions/checkout@v2 + - name: Build the x86_64 Docker image + uses: docker/build-push-action@v1.1.0 + with: + push: false + repository: hyzual/koel + tags: test + - name: Run goss tests on x86_64 image + run: dgoss run hyzual/koel:test diff --git a/Dockerfile b/Dockerfile index 366288c..f2cfeb7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ FROM alpine:3.12.0 as front-builder # Add nodejs and yarn. bash and the other 8 deps are needed to build pngquant, which is a dev dependency for koel... RUN apk add --no-cache nodejs \ - python3 bash lcms2-dev libpng-dev gcc g++ make autoconf automake \ + python2 python3 bash lcms2-dev libpng-dev gcc g++ make autoconf automake \ yarn # Copy sources from php builder @@ -52,7 +52,7 @@ COPY --from=php-builder /tmp/koel /tmp/koel # Install, build frontend assets and then delete the sources to save disk space RUN cd /tmp/koel/resources/assets && \ # Skip cypress download and installation. It is not needed for a production image - yarn install --non-interactive && \ + yarn install --non-interactive --network-timeout 100000 && \ cd /tmp/koel/ && \ CYPRESS_INSTALL_BINARY=0 yarn install --non-interactive && \ yarn run production && \ diff --git a/Makefile b/Makefile index 29df426..f6d423a 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,12 @@ all: build-docker-image -build-docker-image: ## Builds the production Docker build-docker-image +build-docker-image: ## Builds the production x86_64 Docker image docker build . --file Dockerfile --tag hyzual/koel-dev:latest +build-all-arch-docker-images: ## Builds the production Docker image for all supported processor architectures + docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64 . --file Dockerfile --tag hyzual/koel-dev:latest + dgoss-ci: ## Run goss tests on the production Docker image dgoss run hyzual/koel-dev:latest