From f66158a4da111952e52a274bb770b08c21362fe7 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 20 Dec 2021 16:58:37 +0000 Subject: [PATCH 1/5] Add CI --- .dockerignore | 1 + .github/workflows/publish.yaml | 41 ++++++++++++++++++++++++++++++++++ Dockerfile | 14 ++++++++++++ scripts/dockerbuild.sh | 26 +++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/publish.yaml create mode 100644 Dockerfile create mode 100755 scripts/dockerbuild.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..e356c40 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,41 @@ +name: Build & publish images to the package registry for tags + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + name: Build & publish + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check it out + uses: actions/checkout@v2 + + - name: Log in to container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e6cf289 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:16-buster as builder + +WORKDIR /src + +COPY . /src/matrix-video-chat +RUN matrix-video-chat/scripts/dockerbuild.sh + +# App +FROM nginx:alpine + +COPY --from=builder /src/matrix-video-chat/dist /app + +RUN rm -rf /usr/share/nginx/html \ + && ln -s /app /usr/share/nginx/html diff --git a/scripts/dockerbuild.sh b/scripts/dockerbuild.sh new file mode 100755 index 0000000..4a1640b --- /dev/null +++ b/scripts/dockerbuild.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -ex + +git clone https://github.com/matrix-org/matrix-js-sdk.git +cd matrix-js-sdk +git checkout robertlong/group-call +yarn install +yarn run build +yarn link +cd .. + +git clone https://github.com/matrix-org/matrix-react-sdk.git +cd matrix-react-sdk +git checkout robertlong/group-call +yarn link matrix-js-sdk +yarn install +yarn run build +yarn link +cd .. + +cd matrix-video-chat +yarn link matrix-js-sdk +yarn link matrix-react-sdk +yarn install +yarn run build From ccd8b484a6ab1759abcc19ec7996ef4ed3f8bfe9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 20 Dec 2021 17:53:23 +0000 Subject: [PATCH 2/5] Add env vars to build script with hardcoded values for now --- scripts/dockerbuild.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/dockerbuild.sh b/scripts/dockerbuild.sh index 4a1640b..eb1fb13 100755 --- a/scripts/dockerbuild.sh +++ b/scripts/dockerbuild.sh @@ -2,6 +2,9 @@ set -ex +VITE_DEFAULT_HOMESERVER=https://call.ems.host +VITE_SENTRY_DSN=https://b1e328d49be3402ba96101338989fb35@sentry.matrix.org/41 + git clone https://github.com/matrix-org/matrix-js-sdk.git cd matrix-js-sdk git checkout robertlong/group-call From 032d623acb82e239dbe2c2fbdd65facf0d8eb01f Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 20 Dec 2021 18:43:45 +0000 Subject: [PATCH 3/5] Use unprivilged nginx image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e6cf289..4d222bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY . /src/matrix-video-chat RUN matrix-video-chat/scripts/dockerbuild.sh # App -FROM nginx:alpine +FROM nginxinc/nginx-unprivileged:alpine COPY --from=builder /src/matrix-video-chat/dist /app From 31845dea103746514d58de4a0c379cc73fcf9f57 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 20 Dec 2021 20:05:05 +0000 Subject: [PATCH 4/5] Fix docker build and add catchall route --- Dockerfile | 8 ++++++-- scripts/default.conf | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 scripts/default.conf diff --git a/Dockerfile b/Dockerfile index 4d222bc..8855151 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,10 @@ RUN matrix-video-chat/scripts/dockerbuild.sh FROM nginxinc/nginx-unprivileged:alpine COPY --from=builder /src/matrix-video-chat/dist /app +COPY scripts/default.conf /etc/nginx/conf.d/ -RUN rm -rf /usr/share/nginx/html \ - && ln -s /app /usr/share/nginx/html +USER root + +RUN rm -rf /usr/share/nginx/html + +USER 101 diff --git a/scripts/default.conf b/scripts/default.conf new file mode 100644 index 0000000..2af6c30 --- /dev/null +++ b/scripts/default.conf @@ -0,0 +1,10 @@ +server { + listen 8080; + server_name localhost; + + location / { + root /app; + try_files $uri /$uri /index.html; + } +} + From b65874a6fc04a4db9b567b32df2fa7a523d3defb Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 20 Dec 2021 21:00:06 +0000 Subject: [PATCH 5/5] export variables --- scripts/dockerbuild.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/dockerbuild.sh b/scripts/dockerbuild.sh index eb1fb13..92c789b 100755 --- a/scripts/dockerbuild.sh +++ b/scripts/dockerbuild.sh @@ -2,8 +2,8 @@ set -ex -VITE_DEFAULT_HOMESERVER=https://call.ems.host -VITE_SENTRY_DSN=https://b1e328d49be3402ba96101338989fb35@sentry.matrix.org/41 +export VITE_DEFAULT_HOMESERVER=https://call.ems.host +export VITE_SENTRY_DSN=https://b1e328d49be3402ba96101338989fb35@sentry.matrix.org/41 git clone https://github.com/matrix-org/matrix-js-sdk.git cd matrix-js-sdk