From 3104717592c3fb304ffc9e9073b37760ce7b1d33 Mon Sep 17 00:00:00 2001 From: James <11054922+entrancedjames@users.noreply.github.com> Date: Mon, 11 Apr 2022 09:52:50 -0700 Subject: [PATCH] Dockerize Service to begin testing in prod (#23) Dockerize service and have hasura front-end --- Dockerfile | 47 +++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 51 +++++++++++++++++++++++++++++++++++++++++++ src/util/gov_token.rs | 1 + 3 files changed, 99 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..771dec8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +FROM cosmwasm/wasmd:v0.18.0 as wasmd +FROM cosmwasm/rust-optimizer:0.11.5 as rust-optimizer +FROM ubuntu:20.04 +FROM postgres:14 + +COPY --from=wasmd /usr/bin/wasmd /usr/local/bin/wasmd +COPY --from=wasmd /opt/* /opt/ + +RUN apt-get update && \ + apt-get install --no-install-recommends -y \ + ca-certificates curl file \ + build-essential \ + git \ + gcc \ + jq \ + musl-tools \ + autoconf automake autotools-dev libtool xutils-dev + +RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata +RUN apt-get install -y postgresql-server-dev-14 postgresql-contrib + +ENV SSL_VERSION=1.0.2u + +RUN curl https://www.openssl.org/source/openssl-$SSL_VERSION.tar.gz -O && \ + tar -xzf openssl-$SSL_VERSION.tar.gz && \ + cd openssl-$SSL_VERSION && ./config && make depend && make install && \ + cd .. && rm -rf openssl-$SSL_VERSION* + +ENV OPENSSL_LIB_DIR=/usr/local/ssl/lib \ + OPENSSL_INCLUDE_DIR=/usr/local/ssl/include \ + OPENSSL_STATIC=1 + + +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y +ENV PATH=/root/.cargo/bin:$PATH +RUN rustup update stable \ + && rustup target add wasm32-unknown-unknown + +RUN cargo install diesel_cli --no-default-features --features "postgres" + +RUN git clone https://github.com/DA0-DA0/dao-contracts.git +RUN mkdir /app +ADD . /app +WORKDIR /app +RUN cargo build +CMD cargo run + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3649fdd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,51 @@ +version: "3.9" + +services: + db: + container_name: indexer_db + image: postgres:14 + volumes: + - ./data/db:/var/lib/postgresql/data + environment: + - POSTGRES_DB=postgres + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - '5432:5432' + indexer: + build: . + command: bash -c "cargo install diesel_cli --no-default-features --features "postgres" && diesel setup && diesel migration run && cargo run" + volumes: + - .:/code + network_mode: host + environment: + - POSTGRES_NAME=postgres + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - ENABLE_INDEXER=true + - TENDERMINT_WEBSOCKET_URL=wss://rpc.uni.juno.deuslabs.fi/websocket + - TENDERMINT_RPC_URL=https://rpc.uni.juno.deuslabs.fi + - TENDERMINT_SAVE_ALL_BLOCKS=true + - TENDERMINT_INITAL_BLOCK_HEIGHT=100000 + - RUST_BACKTRACE=1 + - DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres + depends_on: + - db + graphql-engine: + image: hasura/graphql-engine:v2.4.0 + ports: + - "8080:8080" + depends_on: + - db + environment: + ## postgres database to store Hasura metadata + HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgres@indexer_db:5432/postgres + ## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs + PG_DATABASE_URL: postgres://postgres:postgres@indexer_db:5432/postgres + ## enable the console served by server + HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console + ## enable debugging mode. It is recommended to disable this in production + HASURA_GRAPHQL_DEV_MODE: "true" + HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log + ## uncomment next line to set an admin secret + # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey diff --git a/src/util/gov_token.rs b/src/util/gov_token.rs index afb6c21..7736ecf 100644 --- a/src/util/gov_token.rs +++ b/src/util/gov_token.rs @@ -75,6 +75,7 @@ pub fn insert_gov_token( // stake_contract_code_id, label, // unstaking_duration, + .. } => { warn!("TODO: Use existing cw20 addr: {}, label: {},", addr, label); result = Ok(0);