Multi-platform docker build without qemu
see also https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
This commit is contained in:
parent
ca943f1978
commit
3e87d8b52e
2 changed files with 11 additions and 11 deletions
18
.github/workflows/push.yml
vendored
18
.github/workflows/push.yml
vendored
|
@ -11,14 +11,14 @@ jobs:
|
|||
- uses: actions/checkout@v2.4.0
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2.4.1
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v2.1.6
|
||||
- uses: actions/cache@v2.1.7
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
|
@ -86,12 +86,12 @@ jobs:
|
|||
docker:
|
||||
needs: install
|
||||
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')
|
||||
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
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v2.1.7
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
|
@ -100,12 +100,12 @@ jobs:
|
|||
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: docker/metadata-action@v3.6.0
|
||||
uses: docker/metadata-action@v3.6.2
|
||||
with:
|
||||
images: haishanh/yacd
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1.2.0
|
||||
# - name: Set up QEMU
|
||||
# uses: docker/setup-qemu-action@v1.2.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
|
@ -134,8 +134,8 @@ jobs:
|
|||
push: true
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM node:alpine AS builder
|
||||
FROM --platform=$BUILDPLATFORM node:alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
# Using yarn to install dependencies in CI will cause network timeout
|
||||
|
@ -9,7 +9,7 @@ RUN yarn config set network-timeout 300000 \
|
|||
# remove source maps - people like small image
|
||||
&& rm public/*.map || true
|
||||
|
||||
FROM nginx:alpine
|
||||
FROM --platform=$TARGETPLATFORM nginx:alpine
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
COPY --from=builder /app/public /usr/share/nginx/html
|
||||
ENV YACD_DEFAULT_BACKEND "http://127.0.0.1:9090"
|
||||
|
|
Loading…
Reference in a new issue