diff --git a/Makefile b/Makefile index 886dbe7b..bdc93dfc 100644 --- a/Makefile +++ b/Makefile @@ -82,3 +82,24 @@ migrate: $(MIGRATE) checkdbvars import: test -n "$(NAME)" # $$NAME psql $(NAME) < db/schema.sql + +#Dev environment +DEV_COMPOSE_FILE=dockerfiles/dev/docker-compose.yml + +.PHONY: dev_env_up +dev_env_up: + docker-compose -f $(DEV_COMPOSE_FILE) up -d geth + docker-compose -f $(DEV_COMPOSE_FILE) up --build migrations + docker-compose -f $(DEV_COMPOSE_FILE) up -d --build vulcanizedb + +.PHONY: dev_env_deploy +dev_env_deploy: + docker-compose -f $(DEV_COMPOSE_FILE) up -d --build vulcanizedb + +.PHONY: dev_env_migrate +dev_env_migrate: + docker-compose -f $(DEV_COMPOSE_FILE) up --build migrations + +.PHONY: dev_env_down +dev_env_down: + docker-compose -f $(DEV_COMPOSE_FILE) down diff --git a/dockerfiles/dev/Dockerfile b/dockerfiles/dev/Dockerfile new file mode 100644 index 00000000..7f5d5a7b --- /dev/null +++ b/dockerfiles/dev/Dockerfile @@ -0,0 +1,9 @@ +FROM golang:1.10.3-alpine3.7 + +RUN apk add --no-cache make gcc musl-dev + +ADD . /go/src/github.com/vulcanize/vulcanizedb +WORKDIR /go/src/github.com/vulcanize/vulcanizedb +RUN go build -o /app main.go + +ENTRYPOINT ["/app"] diff --git a/dockerfiles/dev/config.toml b/dockerfiles/dev/config.toml new file mode 100644 index 00000000..7fa6796e --- /dev/null +++ b/dockerfiles/dev/config.toml @@ -0,0 +1,9 @@ +[database] +name = "vulcanizedb" +hostname = "postgres" +port = 5432 +user = "postgres" +password = "postgres" + +[client] +ipcPath = "/geth/geth.ipc" diff --git a/dockerfiles/dev/docker-compose.yml b/dockerfiles/dev/docker-compose.yml new file mode 100644 index 00000000..99ceb1c1 --- /dev/null +++ b/dockerfiles/dev/docker-compose.yml @@ -0,0 +1,48 @@ +version: '2.2' + +services: + + vulcanizedb: + build: + context: ./../../ + dockerfile: dockerfiles/dev/Dockerfile + container_name: dev_vulcanizedb + command: "sync --starting-block-number 0 --config /config.toml" + volumes: + - "./config.toml:/config.toml" + - "vulcanizedb_geth_data:/geth" + + migrations: + image: migrate/migrate:v3.3.0 + container_name: dev_vulcanizedb_migrations + depends_on: + postgres: + condition: service_healthy + command: -database postgresql://postgres:postgres@postgres:5432/vulcanizedb?sslmode=disable -path /migrations up + volumes: + - ./../../db/migrations:/migrations + + postgres: + image: postgres:9.6.5-alpine + container_name: dev_vulcanizedb_postgres + environment: + POSTGRES_USER: postgres + POSTGRES_DB: vulcanizedb + POSTGRES_PASSWORD: postgres + healthcheck: + test: ["CMD", "pg_isready"] + interval: 5s + timeout: 5s + retries: 30 + + geth: + image: ethereum/client-go:v1.8.11 + container_name: dev_vulcanizedb_geth + cpus: 0.3 + hostname: eth + command: '--rinkeby --rpc --rpcaddr="0.0.0.0" --rpcvhosts="geth"' + volumes: + - "vulcanizedb_geth_data:/root/.ethereum/rinkeby" + +volumes: + vulcanizedb_geth_data: