diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ad79056b --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/Makefile b/Makefile index 188f8230..fca5cbb0 100644 --- a/Makefile +++ b/Makefile @@ -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 . \ No newline at end of file diff --git a/db/migrations/00004_create_postgraphile_comments.sql b/db/migrations/00004_create_postgraphile_comments.sql new file mode 100644 index 00000000..a874b17e --- /dev/null +++ b/db/migrations/00004_create_postgraphile_comments.sql @@ -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'; diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 5ca9054f..0c476d57 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -3,23 +3,21 @@ 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 @@ -27,13 +25,12 @@ 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 diff --git a/dockerfiles/docker-compose.yml b/dockerfiles/docker-compose.yml index e4089b07..3d00e18a 100644 --- a/dockerfiles/docker-compose.yml +++ b/dockerfiles/docker-compose.yml @@ -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 @@ -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 @@ -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: \ No newline at end of file diff --git a/dockerfiles/header_sync/Dockerfile b/dockerfiles/header_sync/Dockerfile index 940009fd..247977d5 100644 --- a/dockerfiles/header_sync/Dockerfile +++ b/dockerfiles/header_sync/Dockerfile @@ -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 diff --git a/dockerfiles/postgraphile/Dockerfile b/dockerfiles/postgraphile/Dockerfile deleted file mode 100644 index 8ce064bb..00000000 --- a/dockerfiles/postgraphile/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM node:alpine - -RUN npm install -g postgraphile -RUN npm install -g postgraphile-plugin-connection-filter -RUN npm install -g @graphile/pg-pubsub - -EXPOSE 5000 -ENTRYPOINT ["postgraphile"] \ No newline at end of file diff --git a/environments/example.toml b/environments/example.toml index eabb307b..5169bfc9 100644 --- a/environments/example.toml +++ b/environments/example.toml @@ -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 \ No newline at end of file + startingBlock = 10564606 + +#[log] +# level = "debug" \ No newline at end of file