From 71bbd9d1e214b687cfdf80f05a3495a468908116 Mon Sep 17 00:00:00 2001 From: Fuxing Loh <4266087+fuxingloh@users.noreply.github.com> Date: Thu, 17 Feb 2022 13:24:07 +0800 Subject: [PATCH] feat(workflow): docker-buildx workflow (#1070) * add initial sanity testing container * remove legacy test * use base docker file as root context * adding just the root apps workflow * add document ignore to speed up build time with less context to transfer * remove sanity check first * build all instead * add build-args instead of building multiple images Co-authored-by: Kodemon --- .dockerignore | 11 +++++++++++ .github/workflows/ci.yml | 24 +++++++++++++++++++++++- Dockerfile | 28 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..0916a635ad --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.idea +.husky +.github +docs +examples + +node_modules + +__tests__ +dist +tsconfig.build.tsbuildinfo diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dabc12fdeb..8df175a656 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: strategy: fail-fast: false matrix: - instance: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + instance: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] env: GH_INSTANCE_TOTAL: 10 steps: @@ -61,3 +61,25 @@ jobs: - run: npm ci - run: npx --no-install eslint . + + docker-buildx: + name: Docker Buildx + runs-on: ubuntu-latest + strategy: + matrix: + platform: [ linux/amd64, linux/arm64 ] + app: [ legacy-api, ocean-api ] + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 + + - name: Build platforms + uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b + with: + push: false + build-args: APP=${{ matrix.app }} + platforms: ${{ matrix.platform }} + tags: ghcr.io/defich/${{ matrix.app }}:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..b35c28db03 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM node:16-alpine3.13 + +# Add curl to use docker healthcheck capability +RUN apk --no-cache add curl + +WORKDIR /app + +COPY LICENSE ./ + +COPY lerna.json ./ +COPY tsconfig.base.json ./ +COPY tsconfig.build.json ./ +COPY tsconfig.json ./ + +COPY package.json ./ +COPY package-lock.json ./ + +COPY packages ./packages +COPY apps ./apps + +RUN npm ci +RUN npx lerna run build --ignore @defichain-apps/website + +ARG APP +ENV APP ${APP} +RUN ln -s apps/${APP}/dist/apps/${APP}/src ${APP} + +CMD "node" ${APP}