From e2ad5775fbb42201ae8a2e0d220d797cc015f2b4 Mon Sep 17 00:00:00 2001 From: Marcin Wolny Date: Wed, 14 Sep 2022 12:11:46 +0200 Subject: [PATCH] Hello Github actions --- .github/workflows/docker.yml | 57 +++++++++++++++++++++++++++++++++++ event-pipeline-evm/Dockerfile | 28 ++++++++++++----- event-pipeline/Dockerfile | 20 +++++++----- staking-api/Dockerfile | 18 ++++++++--- 4 files changed, 102 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..e9ff30b5 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,57 @@ +name: docker + +on: + pull_request: + branches: + - master + push: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# This is required by aws-actions. +# +permissions: + id-token: write + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: hadolint/hadolint-action@v2.1.0 + with: + recursive: true + ignore: DL3018 + + build: + runs-on: ubuntu-latest + strategy: + matrix: + build: + - dockerfile: event-pipeline-evm/Dockerfile + name: event-pipeline-evm + - dockerfile: event-pipeline/Dockerfile + name: event-pipeline + - dockerfile: staking-api/Dockerfile + name: staking-api + steps: + - uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.AWSROLE }} + aws-region: us-east-1 + - uses: aws-actions/amazon-ecr-login@v1 + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + - uses: docker/build-push-action@v3 + with: + push: ${{ github.ref == 'ref/heads/master' }} + context: . + file: ${{ matrix.build.dockerfile }} + platforms: linux/amd64 + tags: ${{ secrets.REGISTRY }}/0x/${{ matrix.build.name }}:${{ github.sha }} diff --git a/event-pipeline-evm/Dockerfile b/event-pipeline-evm/Dockerfile index d18ef0d0..f3d84d48 100644 --- a/event-pipeline-evm/Dockerfile +++ b/event-pipeline-evm/Dockerfile @@ -1,38 +1,50 @@ # Stage 1 - Build -FROM node:12-alpine as build +# +FROM node:12-alpine AS build WORKDIR /usr/src/app # Install app dependencies COPY event-pipeline-evm event-pipeline-evm COPY pipeline-utils pipeline-utils COPY package.json yarn.lock tsconfig.json lerna.json ./ -RUN apk update && \ - apk upgrade && \ - apk add --no-cache --virtual build-dependencies bash git openssh python3 make g++ && \ - yarn --frozen-lockfile --no-cache -RUN yarn build +RUN apk add --update --no-cache --virtual build-dependencies \ + bash \ + git \ + openssh \ + python3 \ + make \ + g++ && \ + yarn --frozen-lockfile --no-cache && \ + yarn build # Stage 2 +# FROM node:12-alpine WORKDIR /usr/src/app # Setup monorepo +# COPY package.json yarn.lock tsconfig.json lerna.json ./ # Setup pipeline-utils +# COPY pipeline-utils/package.json pipeline-utils/ COPY --from=build /usr/src/app/pipeline-utils/lib pipeline-utils/lib # Install event-pipeline-evm runtime dependencies +# COPY event-pipeline-evm/package.json event-pipeline-evm/ -RUN apk add git && \ +RUN apk add --update --no-cache git && \ yarn install --frozen-lockfile --no-cache --production && \ + yarn cache clean && \ apk del git # Copy built files +# COPY --from=build /usr/src/app/event-pipeline-evm/lib event-pipeline-evm/lib/ -#Start +# Start +# WORKDIR /usr/src/app/event-pipeline-evm CMD [ "yarn", "migrate_and_start" ] diff --git a/event-pipeline/Dockerfile b/event-pipeline/Dockerfile index 9d732a2a..973f9fcd 100644 --- a/event-pipeline/Dockerfile +++ b/event-pipeline/Dockerfile @@ -1,17 +1,16 @@ # Stage 1 - Build -FROM node:12-alpine as build +# +FROM node:12-alpine AS build WORKDIR /usr/src/app # Install app dependencies COPY event-pipeline event-pipeline COPY pipeline-utils pipeline-utils COPY package.json yarn.lock tsconfig.json lerna.json ./ -RUN apk update && \ - apk upgrade && \ - apk add --no-cache --virtual build-dependencies bash git openssh python3 make g++ && \ - yarn --frozen-lockfile --no-cache -RUN yarn build +RUN apk add --update --no-cache --virtual build-dependencies bash git openssh python3 make g++ && \ + yarn --frozen-lockfile --no-cache && \ + yarn build # Stage 2 FROM node:12-alpine @@ -26,9 +25,14 @@ COPY --from=build /usr/src/app/pipeline-utils/lib pipeline-utils/lib # Install event-pipeline runtime dependencies COPY event-pipeline/package.json event-pipeline/ -RUN apk add git python3 make g++ && \ +RUN apk add --update --no-cache --virtual build-dependencies \ + git \ + python3 \ + make \ + g++ && \ yarn install --frozen-lockfile --no-cache --production && \ - apk del git python3 make g++ + apk del build-dependencies && \ + yarn cache clean # Copy built files COPY --from=build /usr/src/app/event-pipeline/lib event-pipeline/lib/ diff --git a/staking-api/Dockerfile b/staking-api/Dockerfile index 83092e74..cd573ece 100644 --- a/staking-api/Dockerfile +++ b/staking-api/Dockerfile @@ -1,14 +1,20 @@ # Stage 1 FROM node:12-alpine as build + WORKDIR /usr/src/app # Install app dependencies COPY staking-api staking-api COPY package.json yarn.lock tsconfig.json lerna.json ./ -RUN apk update && \ - apk upgrade && \ - apk add --no-cache --virtual build-dependencies bash git openssh python3 make g++ && \ + +RUN apk add --update --no-cache --virtual build-dependencies \ + bash \ + git \ + openssh \ + python3 \ + make \ + g++ && \ yarn --frozen-lockfile --no-cache - + RUN yarn build # Stage 2 @@ -20,7 +26,9 @@ ENV NODE_ENV=production # Install runtime dependencies COPY staking-api/package.json yarn.lock ./ -RUN yarn install --frozen-lockfile --no-cache + +RUN yarn install --frozen-lockfile && \ + yarn cache clean # Copy built files COPY --from=build /usr/src/app/staking-api/lib /usr/src/app/staking-api/lib