feat: use buildx for multi-arch docker image build (#3603)

This commit is contained in:
Henry Wang
2019-12-20 10:18:39 +00:00
committed by DIYgod
parent ed7f05464a
commit 4253dd11e0
6 changed files with 87 additions and 62 deletions

40
.github/workflows/docker-release.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: '[docker] CI for releases'
on:
push:
branches: master
paths:
- 'lib/**'
- 'Dockerfile'
- 'package.json'
jobs:
release:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v1
-
name: Dockerhub login
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
-
name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
-
name: Build dockerfile (with push)
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
docker buildx build \
--platform=linux/amd64,linux/arm/v7,linux/arm64 \
--output "type=image,push=true" \
--file ./Dockerfile . \
--tag $(echo "${DOCKER_USERNAME}" | tr '[:upper:]' '[:lower:]')/rsshub:latest

36
.github/workflows/docker-test.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: '[docker] CI for build tests'
on:
pull_request:
branches: master
paths:
- 'lib/**'
- 'Dockerfile'
- 'package.json'
push:
branches: '*'
paths:
- 'lib/**'
- 'Dockerfile'
- 'package.json'
jobs:
test:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v1
-
name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
-
name: Build dockerfile (without push)
run: |
docker buildx build \
--platform=linux/amd64,linux/arm/v7,linux/arm64 \
--output "type=image,push=false" \
--file ./Dockerfile .

View File

@@ -1,24 +1,25 @@
FROM node:10.15-slim
FROM node:10-slim
LABEL MAINTAINER https://github.com/DIYgod/RSSHub/
RUN apt-get update && apt-get install -yq libgconf-2-4 apt-transport-https git --no-install-recommends && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_ENV production
ENV TZ Asia/Shanghai
ARG USE_CHINA_NPM_REGISTRY=0;
ARG PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1;
RUN apt-get update && apt-get install -yq libgconf-2-4 apt-transport-https git dumb-init --no-install-recommends && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json /app
ARG USE_CHINA_NPM_REGISTRY=0;
RUN if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
echo 'use npm mirror'; npm config set registry https://registry.npm.taobao.org; \
fi;
ARG PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1;
RUN if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ]; then \
apt-get install -y wget --no-install-recommends \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
@@ -28,7 +29,7 @@ RUN if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ]; then \
--no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge --auto-remove -y curl \
&& apt-get purge --auto-remove -y wget\
&& rm -rf /src/*.deb \
&& npm install --production; \
else \
@@ -36,11 +37,9 @@ RUN if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ]; then \
npm install --production; \
fi;
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
COPY . /app
EXPOSE 1200
ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "run", "start"]

View File

@@ -1,24 +0,0 @@
FROM arm32v7/node:8.16-alpine
ARG USE_CHINA_NPM_REGISTRY=0;
ENV NODE_ENV production
WORKDIR /app
RUN apk add dumb-init git python vips-dev fftw-dev build-base --update-cache --repository https://alpine.global.ssl.fastly.net/alpine/edge/community/ --repository https://alpine.global.ssl.fastly.net/alpine/edge/main
COPY package.json /app
RUN if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
echo 'use npm mirror'; npm config set registry https://registry.npm.taobao.org; \
fi;
# 跳过Chromium下载puppeteer不会下载chrome-arm
RUN export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
&& npm install --production
COPY . /app
EXPOSE 1200
ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "run", "start"]

View File

@@ -1,26 +0,0 @@
FROM arm64v8/node:8.16-alpine
RUN apk add dumb-init git python vips-dev fftw-dev build-base --update-cache --repository https://alpine.global.ssl.fastly.net/alpine/edge/community/ --repository https://alpine.global.ssl.fastly.net/alpine/edge/main
ARG USE_CHINA_NPM_REGISTRY=0
ENV NODE_ENV production
WORKDIR /app
COPY package.json /app
RUN if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
echo 'use npm mirror'; npm config set registry https://registry.npm.taobao.org; \
fi;
# 跳过Chromium下载puppeteer不会下载chrome-arm
RUN export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
&& npm install --production
COPY . /app
EXPOSE 1200
ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "run", "start"]

View File

@@ -21,7 +21,7 @@ services:
restart: always
db.redis:
image: redis
image: redis:alpine
restart: always
volumes:
- redis-data:/data