Browse Source

Merge pull request #293 from azrikahar/docker-multiarch-workflow

Docker multiarch workflow
pull/301/head
Pranav C 3 years ago committed by GitHub
parent
commit
2d487ee788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 77
      .github/workflows/docker.yml
  2. 64
      packages/nocodb/Dockerfile

77
.github/workflows/docker.yml

@ -0,0 +1,77 @@
name: docker
on:
workflow_dispatch:
inputs:
tag:
description: "Docker image tag"
required: true
jobs:
buildx:
runs-on: ubuntu-latest
env:
working-directory: ./packages/nocodb
strategy:
matrix:
node-version: [12]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- uses: bahmutov/npm-install@v1
with:
working-directory: ${{ env.working-directory }}
- name: Build nocodb and docker files
run: |
npm run build
npm run docker:build
working-directory: ${{ env.working-directory }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ env.working-directory }}
build-args: NC_VERSION=${{ github.event.inputs.tag }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
push: true
tags: |
nocodb/nocodb:${{ github.event.inputs.tag }}
nocodb/nocodb:latest
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

64
packages/nocodb/Dockerfile

@ -1,52 +1,44 @@
FROM alpine:3.12 ###########
# Builder
# Bug fix for segfault ( Convert PT_GNU_STACK program header into PT_PAX_FLAGS ) ###########
#RUN apk --update --no-cache add paxctl \ FROM node:12 as builder
# && paxctl -cm $(which node) WORKDIR /usr/src/app
ENV NODE_ENV production
ENV NC_VERSION 0.6
ENV NC_DOCKER 0.6
ENV PORT 8080 ENV PORT 8080
ENV NODE_ENV=dev
#ENV TOOL_DIR=/tool
ENV NC_VERSION=0.6
ENV NC_DOCKER=0.6
# Create and change to the app directory.
WORKDIR /usr/src/appTemp
# Copy application dependency manifests to the container image. # Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied. # A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change. # Copying this separately prevents re-running npm ci on every code change.
#COPY ./build/ ./build/ COPY ./package*.json ./
COPY ./docker/main.js ./docker/main.js COPY ./docker/main.js ./docker/main.js
COPY ./package.json ./
COPY ./docker/start.sh /usr/src/appEntry/start.sh COPY ./docker/start.sh /usr/src/appEntry/start.sh
# Install production dependencies. # install production dependencies,
#RUN npm i ../xc-lib-gui/ && npm install --cache=/usr/src/app/cache --production && npx modclean --patterns="default:*" --run && rm -rf /usr/src/app/cache && rm -rf /root/.npm # reduce node_module size with modclean & removing sqlite deps,
RUN apk --update --no-cache add \ # package built code into app.tar.gz & add execute permission to start.sh
nodejs \ RUN npm ci --production --quiet \
nodejs-npm \
tar\
&& npm install --cache=/usr/src/app/cache --production \
&& npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**" --run \ && npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**" --run \
&& rm -rf ./node_modules/sqlite3/deps \ && rm -rf ./node_modules/sqlite3/deps \
# && rm -rf ./node_modules/nc-lib-gui/lib/dist/_nuxt \ && tar -czf ../appEntry/app.tar.gz ./* \
&& rm -rf /usr/src/app/cache && rm -rf /root/.npm \ && chmod +x /usr/src/appEntry/start.sh
&& apk del nodejs-npm \
&& tar -czf ../appEntry/app.tar.gz ./* ; rm -rf ./* && chmod +x /usr/src/appEntry/start.sh
##########
#COPY ./node_modules/xc-lib/ ./node_modules/xc-lib/ # Runner
#COPY ./node_modules/xc-lib-gui/ ./node_modules/xc-lib-gui/ ##########
FROM alpine:3.12
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Run the web service on container startup. RUN apk --update --no-cache add \
#CMD [ "node", "docker/index.js" ] nodejs \
ENTRYPOINT ["sh", "/usr/src/appEntry/start.sh"] tar
# Copy packaged production code & main entry file
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/
EXPOSE 8080
# Start Nocodb
ENTRYPOINT ["sh", "/usr/src/appEntry/start.sh"]
Loading…
Cancel
Save