From b4b65bb90624ad00e6e3336c276a363548fb60cc Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sun, 5 Jul 2020 19:22:25 +0200 Subject: [PATCH] :whale: Build Raspberry Pi Docker image correctly --- .github/workflows/docker-images-rpi.yml | 28 ++++++++++++++ .github/workflows/docker-images.yml | 5 --- docker/images/n8n-custom/Dockerfile copy | 49 ++++++++++++++++++++++++ docker/images/n8n-rhel7/Dockerfile | 23 +++++++++++ docker/images/n8n-rhel7/README.md | 16 ++++++++ 5 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/docker-images-rpi.yml create mode 100644 docker/images/n8n-custom/Dockerfile copy create mode 100644 docker/images/n8n-rhel7/Dockerfile create mode 100644 docker/images/n8n-rhel7/README.md diff --git a/.github/workflows/docker-images-rpi.yml b/.github/workflows/docker-images-rpi.yml new file mode 100644 index 0000000000..c6db9ed95b --- /dev/null +++ b/.github/workflows/docker-images-rpi.yml @@ -0,0 +1,28 @@ +name: Docker Image CI - Rpi + +on: + push: + tags: + - n8n@* + +jobs: + armv7_job: + runs-on: ubuntu-18.04 + name: Build on ARMv7 (Rpi) + steps: + - uses: actions/checkout@v1 + - name: Get the version + id: vars + run: echo ::set-output name=tag::$(echo ${GITHUB_REF:14}) + + - name: Log in to Docker registry + run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + version: latest + - name: Run Buildx (push image) + if: success() + run: | + docker buildx build --platform linux/arm/v7 --build-arg N8N_VERSION=${{steps.vars.outputs.tag}} -t n8nio/n8n:${{steps.vars.outputs.tag}}-rpi --output type=image,push=true docker/images/n8n-rpi diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml index b05b6aa714..8d034b5b91 100644 --- a/.github/workflows/docker-images.yml +++ b/.github/workflows/docker-images.yml @@ -32,8 +32,3 @@ jobs: run: docker build --build-arg N8N_VERSION=${{steps.vars.outputs.tag}} -t n8nio/n8n:${{steps.vars.outputs.tag}}-ubuntu docker/images/n8n-ubuntu - name: Push Docker image of version (Ubuntu) run: docker push n8nio/n8n:${{steps.vars.outputs.tag}}-ubuntu - - - name: Build the Docker image of version (Rpi) - run: docker build --build-arg N8N_VERSION=${{steps.vars.outputs.tag}} -t n8nio/n8n:${{steps.vars.outputs.tag}}-rpi docker/images/n8n-rpi - - name: Push Docker image of version (Rpi) - run: docker push n8nio/n8n:${{steps.vars.outputs.tag}}-rpi diff --git a/docker/images/n8n-custom/Dockerfile copy b/docker/images/n8n-custom/Dockerfile copy new file mode 100644 index 0000000000..19f08a16dd --- /dev/null +++ b/docker/images/n8n-custom/Dockerfile copy @@ -0,0 +1,49 @@ +FROM node:12.16-alpine as builder +# FROM node:12.16-alpine + +# Update everything and install needed dependencies +RUN apk add --update graphicsmagick tzdata git tini su-exec + +USER root + +# Install all needed dependencies +RUN apk --update add --virtual build-dependencies python build-base ca-certificates && \ + npm_config_user=root npm install -g full-icu lerna + +ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu + +WORKDIR /data + +COPY lerna.json . +COPY package.json . +COPY packages/cli/ ./packages/cli/ +COPY packages/core/ ./packages/core/ +COPY packages/editor-ui/ ./packages/editor-ui/ +COPY packages/nodes-base/ ./packages/nodes-base/ +COPY packages/workflow/ ./packages/workflow/ +RUN rm -rf node_modules packages/*/node_modules packages/*/dist + +RUN npm install --loglevel notice +RUN lerna bootstrap --hoist +RUN npm run build + + +FROM node:12.16-alpine + +WORKDIR /data + +# Install all needed dependencies +RUN npm_config_user=root npm install -g full-icu + +USER root + +ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu + +COPY --from=builder /data ./ + +RUN apk add --update graphicsmagick tzdata git tini su-exec + +COPY docker/images/n8n-dev/docker-entrypoint.sh /docker-entrypoint.sh +ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"] + +EXPOSE 5678/tcp diff --git a/docker/images/n8n-rhel7/Dockerfile b/docker/images/n8n-rhel7/Dockerfile new file mode 100644 index 0000000000..949d436602 --- /dev/null +++ b/docker/images/n8n-rhel7/Dockerfile @@ -0,0 +1,23 @@ +FROM richxsl/rhel7 + +ARG N8N_VERSION + +RUN if [ -z "$N8N_VERSION" ] ; then echo "The N8N_VERSION argument is missing!" ; exit 1; fi + +RUN \ + yum install -y gcc-c++ make + +RUN \ + curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash - + +RUN \ + sudo yum install nodejs + +# Set a custom user to not have n8n run as root +USER root + +RUN npm_config_user=root npm install -g n8n@${N8N_VERSION} + +WORKDIR /data + +CMD "n8n" diff --git a/docker/images/n8n-rhel7/README.md b/docker/images/n8n-rhel7/README.md new file mode 100644 index 0000000000..015f7ac07f --- /dev/null +++ b/docker/images/n8n-rhel7/README.md @@ -0,0 +1,16 @@ +## Build Docker-Image + +``` +docker build --build-arg N8N_VERSION= -t n8nio/n8n: . + +# For example: +docker build --build-arg N8N_VERSION=0.36.1 -t n8nio/n8n:0.36.1-rhel7 . +``` + + +``` +docker run -it --rm \ + --name n8n \ + -p 5678:5678 \ + n8nio/n8n:0.25.0-ubuntu +```