From c08721226f8e0ec3ee828ac2beee19a4fff47b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=86=89?= Date: Thu, 4 Nov 2021 10:53:14 +0800 Subject: [PATCH] Fix ARM64 compatibility issues (#192) * 2021/11/01/22 Github_Action * Update docker.yml Co-authored-by: github-actions[bot] --- .dockerignore | 2 +- .github/workflows/docker.yml | 126 +++++++++++++++++++++++++++-------- Dockerfile | 2 +- guacd/Dockerfile | 6 +- 4 files changed, 102 insertions(+), 34 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3adeba3..61ac58a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,7 +19,7 @@ bin data docs -guacd +# guacd logs playground screenshot diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c6a64e1..d9cecc6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,41 +1,109 @@ -name: Docker image +name: Docker next-terminal Build on: - push: - branches: - - "master" - paths-ignore: - - ".gitignore" - - "*.md" - - "*.png" + workflow_dispatch: + inputs: + days: + description: 'Number of days.' + required: true + default: "20" jobs: - deploy: + DOCKERHUB_next-terminal_Build: + name: Docker next-terminal Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - - uses: actions/setup-node@v2 + - + name: Private Actions Checkout + uses: actions/checkout@v2.3.4 + - + name: Docker Setup QEMU + uses: docker/setup-qemu-action@v1.2.0 + - + name: Docker Setup Buildx + uses: docker/setup-buildx-action@v1.6.0 + - + name: node Setup + uses: actions/setup-node@v2 with: node-version: '14' - - - run: | + - + name: npm install + run: | cd web npm install npm run build - - - name: Log into registry - run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin - - - name: Build and push image - run: | - docker build -t ghcr.io/${{ github.repository_owner }}/next-terminal -f Dockerfile . - docker push ghcr.io/${{ github.repository_owner }}/next-terminal - - - name: Push to Docker Hub - uses: docker/build-push-action@v1 + - + name: Docker Login + uses: docker/login-action@v1.10.0 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: ${{ github.repository_owner }}/next-terminal - tag_with_ref: true + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - + name: Build and push Docker images + uses: docker/build-push-action@v2.7.0 + with: + context: . + platforms: linux/arm64,linux/amd64 + file: Dockerfile + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/next-terminal:latest + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/next-terminal:cache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/next-terminal:cache,mode=max + + DOCKERHUB_Guacd_Build: + name: Docker Guacd Build + runs-on: ubuntu-latest + steps: + - + name: Private Actions Checkout + uses: actions/checkout@v2.3.4 + - + name: Docker Setup QEMU + uses: docker/setup-qemu-action@v1.2.0 + - + name: Docker Setup Buildx + uses: docker/setup-buildx-action@v1.6.0 + - + name: Docker Login + uses: docker/login-action@v1.10.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - + name: Build and push Docker images + uses: docker/build-push-action@v2.7.0 + with: + context: . + platforms: linux/arm64,linux/amd64 + file: guacd/Dockerfile + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/guacd:1.3.0 + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/guacd:cache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/guacd:cache,mode=max + + DOCKERHUB_Hub_Description: + needs: [DOCKERHUB_next-terminal_Build, DOCKERHUB_Guacd_Build] + name: Docker Build PHP_INIT + runs-on: ubuntu-latest + steps: + - + name: Private Actions Checkout + uses: actions/checkout@v2.3.4 + - + name: Docker Hub Description + uses: peter-evans/dockerhub-description@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + repository: ${{ secrets.DOCKERHUB_USERNAME }}/next-terminal + - + name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@main + with: + token: ${{ secrets.TOKEN_GITHUB }} + repository: ${{ github.repository }} + retain_days: ${{ github.event.inputs.days }} + keep_minimum_runs: 3 diff --git a/Dockerfile b/Dockerfile index 53ddad7..1478309 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ COPY . . RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories RUN apk add gcc g++ -RUN go env && CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -ldflags '-linkmode external -extldflags "-static"' -o next-terminal main.go +RUN go env;ARCH="$(arch)";case "$ARCH" in 'x86_64') export ARCH='amd64';echo $ARCH;; 'aarch64') export ARCH='arm64';echo $ARCH;; 'i386') export ARCH='i386';echo $ARCH;; esac;CGO_ENABLED=1 GOOS=linux GOARCH=$ARCH go build -a -ldflags '-linkmode external -extldflags "-static"' -o next-terminal main.go FROM alpine:latest diff --git a/guacd/Dockerfile b/guacd/Dockerfile index c99ed72..be5b98c 100644 --- a/guacd/Dockerfile +++ b/guacd/Dockerfile @@ -1,8 +1,8 @@ -FROM guacamole/guacd:1.3.0 +FROM xrsec/guacd:1.3.0 LABEL MAINTAINER="helloworld1024@foxmail.com" -COPY ./fonts/Menlo-Regular.ttf /usr/share/fonts/ -COPY ./fonts/SourceHanSansCN-Regular.otf /usr/share/fonts/ +COPY ./guacd/fonts/Menlo-Regular.ttf /usr/share/fonts/ +COPY ./guacd/fonts/SourceHanSansCN-Regular.otf /usr/share/fonts/ RUN mkfontscale && mkfontdir && fc-cache \ No newline at end of file