Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello Github actions #101

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
postgres/
node_modules
176 changes: 0 additions & 176 deletions .drone.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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/[email protected]
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-buildx-action@v2
- uses: docker/build-push-action@v3
with:
push: ${{ github.ref == 'refs/heads/master' }}
context: .
file: ${{ matrix.build.dockerfile }}
platforms: linux/amd64
tags: ${{ secrets.REGISTRY }}/0x/${{ matrix.build.name }}:${{ github.sha }}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
postgres:
image: postgres:9.6
image: postgres:10.14
environment:
- POSTGRES_USER=api
- POSTGRES_PASSWORD=api
Expand Down
28 changes: 20 additions & 8 deletions event-pipeline-evm/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 python 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" ]
22 changes: 13 additions & 9 deletions event-pipeline/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 python 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
Expand All @@ -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 python 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 python make g++
apk del build-dependencies && \
yarn cache clean

# Copy built files
COPY --from=build /usr/src/app/event-pipeline/lib event-pipeline/lib/
Expand Down
53 changes: 53 additions & 0 deletions event-pipeline/migrations/1641418834000-AddOtcOrderFilledEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

const eventsOtcOrderFilledEvents = new Table({
name: 'events.otc_order_filled_events',
columns: [
{ name: 'observed_timestamp', type: 'bigint' },
{ name: 'contract_address', type: 'varchar' },
{ name: 'transaction_hash', type: 'varchar', isPrimary: true },
{ name: 'transaction_index', type: 'bigint' },
{ name: 'log_index', type: 'bigint', isPrimary: true },
{ name: 'block_hash', type: 'varchar' },
{ name: 'block_number', type: 'bigint' },

{ name: 'order_hash', type: 'varchar' },
{ name: 'maker_address', type: 'varchar' },
{ name: 'taker_address', type: 'varchar' },
{ name: 'maker_token_address', type: 'varchar' },
{ name: 'taker_token_address', type: 'varchar' },
{ name: 'maker_token_filled_amount', type: 'numeric' },
{ name: 'taker_token_filled_amount', type: 'numeric' },
],
});

const indexQuery = `
CREATE INDEX otc_order_filled_events_transaction_hash_index
ON events.otc_order_filled_events (transaction_hash);
CREATE INDEX otc_order_filled_events_block_number_index
ON events.otc_order_filled_events (block_number);
CREATE INDEX otc_order_filled_events_maker_address_index
ON events.otc_order_filled_events (maker_address);
CREATE INDEX otc_order_filled_events_order_hash_index
ON events.otc_order_filled_events (order_hash);

`;

const dropIndexQuery = `
DROP INDEX events.otc_order_filled_events_transaction_hash_index;
DROP INDEX events.otc_order_filled_events_block_number_index;
DROP INDEX events.otc_order_filled_events_maker_address_index;
DROP INDEX events.otc_order_filled_events_order_hash_index;
`;

export class AddOtcOrderFilledEvents1641418834000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(eventsOtcOrderFilledEvents);
await queryRunner.query(indexQuery);
}

public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(dropIndexQuery);
await queryRunner.dropTable(eventsOtcOrderFilledEvents);
}
}
Loading