Skip to content

Commit

Permalink
feat: use buildx for multi-arch docker image build (DIYgod#3603)
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryQW authored and DIYgod committed Dec 20, 2019
1 parent ed7f054 commit 4253dd1
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 62 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 36 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -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 .
21 changes: 10 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 - \
Expand All @@ -28,19 +29,17 @@ 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 \
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && \
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"]
24 changes: 0 additions & 24 deletions Dockerfile.arm32v7

This file was deleted.

26 changes: 0 additions & 26 deletions Dockerfile.arm64

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
restart: always

db.redis:
image: redis
image: redis:alpine
restart: always
volumes:
- redis-data:/data
Expand Down

0 comments on commit 4253dd1

Please sign in to comment.