From 6e6076242d2c2f5a4474b69665cd4180b543d5b4 Mon Sep 17 00:00:00 2001 From: Haishan Date: Sun, 6 Mar 2022 17:32:23 +0800 Subject: [PATCH] Push docker image to ghcr --- .github/workflows/push.yml | 17 ++++++++++++----- Dockerfile | 10 +++++----- README.md | 5 ++++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 41ccd98..8c43254 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,10 +5,10 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - node-version: [14.x] + node-version: [16.x] steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v3.0.0 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 @@ -88,7 +88,7 @@ jobs: runs-on: ubuntu-20.04 if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || startsWith(github.event.ref, 'refs/heads/v0.') || github.event.ref == 'refs/heads/master' || github.event.ref == 'refs/heads/test') steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v3.0.0 - name: Cache Docker layers uses: actions/cache@v2.1.7 @@ -119,11 +119,18 @@ jobs: run: echo ${{ steps.buildx.outputs.platforms }} - name: Login to Docker Hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v1.14.1 with: username: ${{ github.actor }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} + - name: Login to GHCR + uses: docker/login-action@v1.10.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -132,7 +139,7 @@ jobs: file: ./Dockerfile platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true - tags: ${{ steps.docker_meta.outputs.tags }} + tags: ${{ steps.docker_meta.outputs.tags }},ghcr.io/${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} cache-from: type=gha cache-to: type=gha diff --git a/Dockerfile b/Dockerfile index fa57c7f..0b04f80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ FROM --platform=$BUILDPLATFORM node:alpine AS builder WORKDIR /app + +COPY yarn.lock package.json . +RUN yarn config set network-timeout 300000 && yarn + COPY . . -# Using yarn to install dependencies in CI will cause network timeout -# Refer to https://github.com/date-fns/date-fns/issues/1004 -RUN yarn config set network-timeout 300000 \ - && yarn \ - && yarn build \ +RUN yarn build \ # remove source maps - people like small image && rm public/*.map || true diff --git a/README.md b/README.md index a3e7f41..e2bf8aa 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,10 @@ The site [http://yacd.haishan.me](http://yacd.haishan.me) is served with HTTP not HTTPS is because many browsers block requests to HTTP resources from a HTTPS website. If you think it's not safe, you could just download the [zip of the gh-pages](https://github.com/haishanh/yacd/archive/gh-pages.zip), unzip and open or serve `index.html` directly. -[Docker image](https://hub.docker.com/r/haishanh/yacd) is also available as `haishanh/yacd`. +Docker image + +- Docker Hub [`haishanh/yacd`](https://hub.docker.com/r/haishanh/yacd) +- GitHub Container Registry [`ghcr.io/haishanh/yacd`](https://github.com/haishanh/yacd/pkgs/container/yacd) ## Development