Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from vulcanize/ci
Browse files Browse the repository at this point in the history
[WIP] #12 Github Actions for PR
  • Loading branch information
AFDudley authored Aug 19, 2020
2 parents f544c70 + 9ce0c5b commit 72facc7
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 60 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Docker Compose Build

on: [pull_request]

jobs:
build:
name: Run docker-compose build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run docker build
run: make docker-build
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,8 @@ rollback_to: $(GOOSE) checkmigration checkdbvars
migrate: $(GOOSE) checkdbvars
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" up
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql

## Build docker image
.PHONY: docker-build
docker-build:
docker build -t vulcanize/eth-contract-watcher -f dockerfiles/Dockerfile .
4 changes: 4 additions & 0 deletions db/migrations/00004_create_postgraphile_comments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- +goose Up
COMMENT ON TABLE public.nodes IS E'@name NodeInfo';
COMMENT ON COLUMN public.nodes.node_id IS E'@name ChainNodeID';
COMMENT ON COLUMN public.headers.node_id IS E'@name HeaderNodeID';
23 changes: 10 additions & 13 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,34 @@ FROM golang:1.13-alpine as builder
RUN apk --update --no-cache add make git g++ linux-headers

# Get and build eth-contract-watcher
ADD . /go/src/github.com/vulcanize/eth-contract-watcher
WORKDIR /go/src/github.com/vulcanize/eth-contract-watcher
ADD . .
RUN GO111MODULE=on GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o eth-contract-watcher .

# Build migration tool
# Copy migration tool
WORKDIR /
RUN git clone https://github.com/pressly/goose.git /go/src/github.com/pressly/goose/
WORKDIR /go/src/github.com/pressly/goose/cmd/goose
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -tags='no_mysql no_sqlite' -o goose .

WORKDIR /go/src/github.com/vulcanize/eth-contract-watcher
ARG GOOSE_VER="v2.6.0"
ADD https://github.com/pressly/goose/releases/download/${GOOSE_VER}/goose-linux64 ./goose
RUN chmod +x ./goose

# app container
FROM alpine

ARG USER
ARG CONFIG_FILE
ARG USER="vdm"
ARG CONFIG_FILE="./environments/example.toml"

RUN adduser -Du 5000 $USER
WORKDIR /app
RUN chown $USER /app
USER $USER

# chown first so dir is writable
# note: using $USER is merged, but not in the stable release yet
COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/eth-contract-watcher/$CONFIG_FILE config.toml
COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/eth-contract-watcher/dockerfiles/startup_script.sh .
COPY --chown=$USER:$USER --from=builder /go/src/github.com/vulcanize/eth-contract-watcher/$CONFIG_FILE config.toml
COPY --chown=$USER:$USER --from=builder /go/src/github.com/vulcanize/eth-contract-watcher/dockerfiles/startup_script.sh .

# keep binaries immutable
COPY --from=builder /go/src/github.com/vulcanize/eth-contract-watcher/eth-contract-watcher eth-contract-watcher
COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose goose
COPY --from=builder /goose goose
COPY --from=builder /go/src/github.com/vulcanize/eth-contract-watcher/db/migrations migrations/vulcanizedb
COPY --from=builder /go/src/github.com/vulcanize/eth-contract-watcher/environments environments

Expand Down
43 changes: 14 additions & 29 deletions dockerfiles/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,15 @@ services:
- "127.0.0.1:8079:5432"

eth-header-sync:
restart: unless-stopped
depends_on:
- contact-watcher-db
build:
context: ./../
cache_from:
- alpine:latest
- golang:1.13
dockerfile: ./dockerfiles/header_sync/Dockerfile
args:
USER: "vdm"
CONFIG_FILE: ./environments/example.toml
image: vulcanize/eth-header-sync:v1.0.0
volumes:
- ./geth.ipc:/geth.ipc
- ../environments/example.toml:/app/config.toml
environment:
- STARTING_BLOCK_NUMBER=3327410
- STARTING_BLOCK_NUMBER=10564606
- VDB_COMMAND=sync
- DATABASE_NAME=vulcanize_public
- DATABASE_HOSTNAME=contact-watcher-db
Expand All @@ -62,11 +56,9 @@ services:
- alpine:latest
- golang:1.13
dockerfile: ./dockerfiles/Dockerfile
args:
USER: "vdm"
CONFIG_FILE: ./environments/example.toml
volumes:
- ./geth.ipc:/geth.ipc
- ../environments/example.toml:/app/config.toml
environment:
- VDB_COMMAND=watch
- DATABASE_NAME=vulcanize_public
Expand All @@ -76,26 +68,19 @@ services:
- DATABASE_PASSWORD=password

contract-watcher-graphql:
restart: always
restart: unless-stopped
depends_on:
- contact-watcher-db
build:
context: ./../
cache_from:
- node:alpine
dockerfile: ./dockerfiles/postgraphile/Dockerfile
expose:
- "5000"
image: vulcanize/postgraphile:v1.0
environment:
- PG_HOST=contact-watcher-db
- PG_PORT=5432
- PG_DATABASE=vulcanize_public
- PG_USER=vdbm
- PG_PASSWORD=password
- SCHEMA=public,header_0xd850942ef8811f2a866692a623011bde52a462c1
ports:
- "127.0.0.1:5000:5000"
command: ["--plugins", "@graphile/pg-pubsub",
"--subscriptions",
"--simple-subscriptions",
"--connection", "postgres://vdbm:password@contact-watcher-db:5432/vulcanize_public",
"--port", "5000",
"-n", "0.0.0.0",
"--schema", "public,eth",
"--append-plugins", "postgraphile-plugin-connection-filter"]

volumes:
vulcanizedb_db_data:
4 changes: 2 additions & 2 deletions dockerfiles/header_sync/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ WORKDIR /go/src/github.com/vulcanize/eth-header-sync
# app container
FROM alpine

ARG USER
ARG CONFIG_FILE
ARG USER="vdm"
ARG CONFIG_FILE="./environments/example.toml"

RUN adduser -Du 5000 $USER
WORKDIR /app
Expand Down
8 changes: 0 additions & 8 deletions dockerfiles/postgraphile/Dockerfile

This file was deleted.

15 changes: 7 additions & 8 deletions environments/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
[contract]
network = ""
addresses = [
"0x314159265dD8dbb310642f98f50C066173C1259b",
"0x8dd5fbCe2F6a956C3022bA3663759011Dd51e73E"
"0xd850942ef8811f2a866692a623011bde52a462c1",
]
[contract.0x314159265dD8dbb310642f98f50C066173C1259b]
abi = '[{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"resolver","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"label","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setSubnodeOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"ttl","type":"uint64"}],"name":"setTTL","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"ttl","outputs":[{"name":"","type":"uint64"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"label","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"resolver","type":"address"}],"name":"NewResolver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"ttl","type":"uint64"}],"name":"NewTTL","type":"event"}]'
startingBlock = 3327417
[contract.0x8dd5fbCe2F6a956C3022bA3663759011Dd51e73E]
[contract.0xd850942ef8811f2a866692a623011bde52a462c1]
abi = '[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"seal","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_bonus","type":"uint256"}],"name":"offerBonus","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"isSealed","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"lastMintedTimestamp","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_isRaw","type":"bool"},{"name":"timestamp","type":"uint32"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"payable":false,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}]'
events = [
"Transfer",
"Issue"
]
methods = [
"balanceOf"
]
startingBlock = 5197514
startingBlock = 10564606

#[log]
# level = "debug"

0 comments on commit 72facc7

Please sign in to comment.