Rework dockerhub builds (#22026)

* WIP

* Attempt to wire up dockerhub building in GHA

* Fix issue with mime types

* Skip linux/arm, Cypress only installs on 64-bit

* Update dockerhub.yaml

* Update comment
pull/22977/head
Michael Telatynski 2022-07-29 14:30:16 +01:00 committed by GitHub
parent 4738dc9da2
commit d86e897ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 19 deletions

57
.github/workflows/dockerhub.yaml vendored Normal file
View File

@ -0,0 +1,57 @@
name: Dockerhub
on:
workflow_dispatch: { }
push:
tags: [ v* ]
schedule:
# This job can take a while, and we have usage limits, so just publish develop only twice a day
- cron: '0 7/12 * * *'
concurrency: ${{ github.ref_name }}
jobs:
buildx:
name: Docker Buildx
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # needed for docker-package to be able to calculate the version
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
vectorim/element-web
tags: |
type=ref,event=branch
type=ref,event=tag
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update repo description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: vectorim/element-web

View File

@ -27,9 +27,6 @@ FROM nginx:alpine
COPY --from=builder /src/webapp /app
# Insert wasm type into Nginx mime.types file so they load correctly.
RUN sed -i '3i\ \ \ \ application/wasm wasm\;' /etc/nginx/mime.types
# Override default nginx config
COPY /nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf

View File

@ -5,7 +5,7 @@ set -ex
# Automatically link to develop if we're building develop, but only if the caller
# hasn't asked us to build something else
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ $USE_CUSTOM_SDKS == false ] && [ $BRANCH == 'develop' ]
if [[ $USE_CUSTOM_SDKS == false ]] && [[ $BRANCH == 'develop' ]]
then
echo "using develop dependencies for react-sdk and js-sdk"
USE_CUSTOM_SDKS=true
@ -13,21 +13,21 @@ then
REACT_SDK_BRANCH='develop'
fi
if [ $USE_CUSTOM_SDKS == false ]
if [[ $USE_CUSTOM_SDKS == false ]]
then
echo "skipping react-sdk and js-sdk installs: USE_CUSTOM_SDKS is false"
exit 0
fi
echo "Linking js-sdk"
git clone --depth 1 --branch $JS_SDK_BRANCH $JS_SDK_REPO js-sdk
git clone --depth 1 --branch $JS_SDK_BRANCH "$JS_SDK_REPO" js-sdk
cd js-sdk
yarn link
yarn --network-timeout=100000 install
cd ../
echo "Linking react-sdk"
git clone --depth 1 --branch $REACT_SDK_BRANCH $REACT_SDK_REPO react-sdk
git clone --depth 1 --branch $REACT_SDK_BRANCH "$REACT_SDK_REPO" react-sdk
cd react-sdk
yarn link
yarn link matrix-js-sdk

View File

@ -1,21 +1,18 @@
#!/bin/sh
#!/bin/bash
set -ex
TAG=$(git describe --tags)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
DIST_VERSION=$TAG
DIST_VERSION=$(git describe --abbrev=0 --tags)
# If the branch comes out as HEAD then we're probably checked out to a tag, so if the thing is *not*
# coming out as HEAD then we're on a branch. When we're on a branch, we want to resolve ourselves to
# a few SHAs rather than a version.
# Docker Hub doesn't always check out the tag and sometimes checks out the branch, so we should look
# for an appropriately tagged branch as well (heads/v1.2.3).
if [[ $BRANCH != HEAD && ! $BRANCH =~ heads/v.+ ]]
DIR=$(dirname "$0")
# If we're not using custom SDKs and on a branch other than master, generate a version akin go develop.element.io
if [[ $USE_CUSTOM_SDKS == false ]] && [[ $BRANCH != 'master' ]]
then
DIST_VERSION=`$(dirname $0)/get-version-from-git.sh`
DIST_VERSION=$("$DIR"/get-version-from-git.sh)
fi
DIST_VERSION=`$(dirname $0)/normalize-version.sh ${DIST_VERSION}`
DIST_VERSION=$("$DIR"/normalize-version.sh "$DIST_VERSION")
VERSION=$DIST_VERSION yarn build
echo $DIST_VERSION > /src/webapp/version
echo "$DIST_VERSION" > /src/webapp/version