Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80749d5
commit 3b132b9
Showing
29 changed files
with
447 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
deps | ||
_build | ||
.git/ | ||
.gitignore | ||
config/dev* | ||
config/test* | ||
Dockerfile | ||
Makefile | ||
README* | ||
test/ | ||
priv/static/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,58 @@ | ||
FROM elixir:latest | ||
MAINTAINER Mason Fischer | ||
RUN apt-get update | ||
RUN apt-get install -y curl wget | ||
RUN apt-get update | ||
RUN apt-get install -y git build-essential libtool autoconf clang libclang-dev llvm librocksdb-dev libgmp-dev | ||
RUN wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz && tar -xf LATEST.tar.gz && cd ./libsodium-stable && ./configure && make && make install | ||
RUN mix local.hex --force && mix local.rebar --force | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
RUN . $HOME/.cargo/env && rustup default nightly | ||
# Copied from https://hexdocs.pm/distillery/guides/working_with_docker.html#the-dockerfile | ||
# Switch alpine once this issue is fixed: https://github.com/rust-lang/rustup.rs/issues/640#issuecomment-274550200 | ||
FROM elixir:1.7.4 AS builder | ||
ARG APP_NAME=blacksmith | ||
ARG APP_VERSION=0.1.0 | ||
ARG MIX_ENV=prod | ||
ARG PHOENIX_SUBDIR=. | ||
ENV APP_NAME=${APP_NAME} \ | ||
APP_VERSION=${APP_VERSION} \ | ||
MIX_ENV=${MIX_ENV} | ||
|
||
WORKDIR /opt/app | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
autoconf \ | ||
build-essential \ | ||
curl \ | ||
git \ | ||
libgmp-dev \ | ||
libtool \ | ||
rebar &&\ | ||
mix local.rebar --force && \ | ||
mix local.hex --force | ||
|
||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly | ||
ENV PATH=/root/.cargo/bin:$PATH | ||
COPY . . | ||
RUN mix do deps.get, deps.compile, compile | ||
|
||
RUN mkdir -p /opt/built | ||
RUN ls rel/hooks | ||
RUN mix release --verbose --env=prod | ||
RUN cp _build/${MIX_ENV}/rel/${APP_NAME}/releases/${APP_VERSION}/${APP_NAME}.tar.gz /opt/built | ||
RUN cd /opt/built && \ | ||
tar -xzf ${APP_NAME}.tar.gz && \ | ||
rm ${APP_NAME}.tar.gz && \ | ||
cp /opt/app/deps/libsecp256k1/priv/libsecp256k1_nif.so lib/libsecp256k1-0.1.10/priv | ||
|
||
RUN find / -name transaction_processor | ||
FROM debian:stretch | ||
ARG APP_NAME | ||
|
||
ENV REPLACE_OS_VARS=true \ | ||
APP_NAME=${APP_NAME} | ||
|
||
WORKDIR /opt/app | ||
|
||
COPY --from=builder /opt/built . | ||
RUN apt-get update && apt-get install -y \ | ||
bash \ | ||
libgmp-dev \ | ||
libssl-dev \ | ||
postgresql-client \ | ||
openssl | ||
|
||
ENV LANG C.UTF-8 | ||
ENV LC_ALL C.UTF-8 | ||
CMD trap 'exit' INT;echo $MIX_ENV; echo $WEB3_URL; /opt/app/bin/${APP_NAME} foreground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
APP_NAME ?= `grep 'app: *:' mix.exs | sed -e 's/\[//g' -e 's/ //g' -e 's/app://' -e 's/[:,]//g'` | ||
APP_VSN ?= `grep 'version:' mix.exs | cut -d '"' -f2` | ||
BUILD ?= `git rev-parse --short HEAD` | ||
|
||
build: | ||
docker build --build-arg APP_NAME=$(APP_NAME) \ | ||
--build-arg APP_VSN=$(APP_VSN) \ | ||
-t $(APP_NAME):$(APP_VSN)-$(BUILD) \ | ||
-t $(APP_NAME):latest . | ||
|
||
run: | ||
docker run --env-file config/docker.env \ | ||
--expose 4045 -p 4045:4045 \ | ||
--rm -it $(APP_NAME):latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
use Mix.Config | ||
|
||
private_key = | ||
<<238, 163, 60, 8, 21, 24, 67, 133, 67, 178, 163, 66, 57, 255, 25, 13, 1, 184, 12, 138, 211, | ||
125, 187, 121, 14, 43, 17, 237, 131, 168, 205, 133>> | ||
|
||
config :blacksmith, base_contracts_path: "./base_contracts" | ||
config :blacksmith, port: 4047 | ||
config :blacksmith, private_key: private_key | ||
|
||
config :blacksmith, | ||
staking_contract_address: | ||
"756d0ABF6235AB135126fe772CDaE195C3DECc0e" |> Base.decode16!(case: :mixed) | ||
|
||
config :ex_wire, private_key, private_key | ||
# private_key: | ||
# <<18, 116, 234, 41, 220, 113, 180, 178, 230, 67, 159, 221, 16, 149, 69, 232, 193, 88, 94, 43, | ||
# 22, 188, 212, 82, 54, 254, 32, 251, 249, 25, 167, 13>> | ||
# config :ethereumex, :web3_url, "ws://localhost:8545/" | ||
# config :ethereumex, :web3_url, "wss://ropsten.infura.io/ws/v3/28d900c929bf4df88e0a4adc9f790e22" | ||
config :ethereumex, :client_type, :websocket | ||
config :ethereumex, :web3_url, "wss://rinkeby.infura.io/ws/v3/28d900c929bf4df88e0a4adc9f790e22" | ||
# config :ethereumex, :client_type, :http | ||
config :blacksmith, :redis_url, "redis://127.0.0.1:6379/" | ||
|
||
config :blacksmith, Blacksmith.Repo, | ||
adapter: Ecto.Adapters.Postgres, | ||
database: "test_mix", | ||
database: "blacksmith_dev", | ||
username: "masonf", | ||
password: "", | ||
hostname: "localhost" | ||
hostname: "localhost", | ||
log: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
MIX_ENV=PROD | ||
APP_NAME=blacksmith | ||
POSTGRES_HOST=postgres | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASS= | ||
POSTGRES_DB=blacksmith | ||
REDIS_URL=redis://redis:6379/ | ||
PORT=4045 | ||
STAKING_CONTRACT_ADDRESS=756d0ABF6235AB135126fe772CDaE195C3DECc0e | ||
WEB3_URL=wss://rinkeby.infura.io/ws | ||
ETHEREUM_PRIVATE_KEY=1274EA29DC71B4B2E6439FDD109545E8C1585E2B16BCD45236FE20FBF919A70D | ||
REPLACE_OS_VARS=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,18 @@ | ||
use Mix.Config | ||
|
||
private_key = | ||
<<238, 163, 60, 8, 21, 24, 67, 133, 67, 178, 163, 66, 57, 255, 25, 13, 1, 184, 12, 138, 211, | ||
125, 187, 121, 14, 43, 17, 237, 131, 168, 205, 133>> | ||
|
||
config :blacksmith, base_contracts_path: "./base_contracts" | ||
config :blacksmith, port: 4047 | ||
config :blacksmith, private_key: private_key | ||
config :blacksmith, port: String.to_integer(System.get_env("PORT") || "4045") | ||
|
||
config :blacksmith, | ||
staking_contract_address: | ||
"756d0ABF6235AB135126fe772CDaE195C3DECc0e" |> Base.decode16!(case: :mixed) | ||
(System.get_env("STAKING_CONTRACT_ADDRESS") || "") |> Base.decode16!(case: :mixed) | ||
|
||
# config :ex_wire, private_key, private_key | ||
# private_key: | ||
# <<18, 116, 234, 41, 220, 113, 180, 178, 230, 67, 159, 221, 16, 149, 69, 232, 193, 88, 94, 43, | ||
# 22, 188, 212, 82, 54, 254, 32, 251, 249, 25, 167, 13>> | ||
config :ethereumex, :web3_url, "wss://ropsten.infura.io/ws/v3/28d900c929bf4df88e0a4adc9f790e22" | ||
# config :ethereumex, :client_type, :websocket | ||
config :ethereumex, :web3_url, System.get_env("WEB3_URL") | ||
config :ethereumex, :client_type, :websocket | ||
|
||
config :blacksmith, Blacksmith.Repo, | ||
adapter: Ecto.Adapters.Postgres, | ||
database: "test_mix", | ||
username: "masonf", | ||
password: "", | ||
hostname: "localhost" | ||
username: System.get_env("DATABASE_USER"), | ||
password: System.get_env("DATABASE_PASS"), | ||
database: System.get_env("DATABASE_NAME"), | ||
hostname: System.get_env("DATABASE_HOST"), | ||
pool_size: 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
version: '3.5' | ||
|
||
services: | ||
blacksmith: | ||
build: . | ||
ports: | ||
- "4045:4045" | ||
env_file: | ||
- config/docker.env | ||
depends_on: | ||
- postgres | ||
- redis | ||
postgres: | ||
image: postgres:10-alpine | ||
# build: | ||
# context: https://github.com/docker-library/postgres.git | ||
# dockerfile: 11/alpine/Dockerfile | ||
# args: | ||
# - POSTGRES_DB=blacksmith | ||
volumes: | ||
- "./tmp/volumes/postgres:/var/lib/postgresql/data" | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
- POSTGRES_DB=blacksmith | ||
redis: | ||
image: redis:5-alpine | ||
volumes: | ||
- "./volumes/redis:/data" | ||
ports: | ||
- "6379:6379" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule Release.Tasks do | ||
def migrate do | ||
{:ok, _} = Application.ensure_all_started(:blacksmith) | ||
|
||
path = Application.app_dir(:blacksmith, ["priv", "repo", "migrations"]) | ||
|
||
Ecto.Migrator.run(Blacksmith.Repo, path, :up, all: true) | ||
end | ||
end |
Oops, something went wrong.