diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 00000000000000..54749765f309b4 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -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 diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 00000000000000..33d9a8ccfc10f3 --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -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 . diff --git a/Dockerfile b/Dockerfile index c565be88b43077..99dccc4313cb10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Dockerfile.arm32v7 b/Dockerfile.arm32v7 deleted file mode 100644 index b1784d4abc901b..00000000000000 --- a/Dockerfile.arm32v7 +++ /dev/null @@ -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"] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 deleted file mode 100644 index f38dcca76a1b2f..00000000000000 --- a/Dockerfile.arm64 +++ /dev/null @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml index 737832ab4df7c3..35647d698fe079 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: restart: always db.redis: - image: redis + image: redis:alpine restart: always volumes: - redis-data:/data