DockerでEOSの開発環境作成を行ってみよう！

##背景
[dockerhub eosio/eos](https://hub.docker.com/r/eosio/eos/)を見ると
*"This image is now deprecated. Future builds will discontinue on January 1st, 2019. This image will be removed on June 1st, 2019."*
と記述があったので，**eosio公式のdockerに頼らなくて済むようにDockerfileを記述して環境構築を行ってみた．**
##1.Dockerfile を作成
```:Dockerfile
FROM ubuntu:18.04

RUN mkdir -p /root/eosio
VOLUME ["/root/eosio"]
RUN \
  apt-get update -y && \
  apt-get upgrade -y && \
  apt-get install -y software-properties-common && \
  apt-get install -y wget && \
  cd /root/eosio && \
  wget https://github.com/EOSIO/eosio.cdt/releases/download/v1.4.1/eosio.cdt-1.4.1.x86_64.deb && \
  apt install ./eosio.cdt-1.4.1.x86_64.deb && \
  wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-1-ubuntu-18.04_amd64.deb &&\
  apt install -y ./eosio_1.6.0-1-ubuntu-18.04_amd64.deb
EXPOSE 8888
EXPOSE 7777
EXPOSE 5555
CMD ["/bin/sh"]
```
##2. Dockerイメージを作成し，起動
```
// eosphi という名前で Dockerfile からイメージをビルド
$ docker build ./ -t eos-docker
Sending build context to Docker daemon  37.38kB
Step 1/9 : FROM ubuntu:18.04
 ---> 20bb25d32758
︙ // 以下略

//docker 起動
$ docker run -it -d --name eosphi \
--publish 7777:7777 \
--publish 5555:5555 \
--volume $(pwd)/:/eos_contracts \
--detach \
eos-docker:latest \
/bin/bash -c \
"keosd --http-server-address=0.0.0.0:5555 & \
exec nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--plugin eosio::http_plugin \
-d /mnt/dev/data \
--config-dir /mnt/dev/config \
--http-server-address=0.0.0.0:7777 \
--access-control-allow-origin=* \
--contracts-console \
--http-validate-host=false \
--filter-on='*'"

```

コンテナ確認

```
$ docker logs --tail eosphi
info  2019-02-08T07:57:50.001 thread-0  producer_plugin.cpp:1549      produce_block        ] Produced block 0003b66e45315d8b... #243310 @ 2019-02-08T07:57:50.000 signed by eosio [trxs: 0, lib: 243309, confirmed: 0]
info  2019-02-08T07:57:50.501 thread-0  producer_plugin.cpp:1549      produce_block        ] Produced block 0003b66f5f395133... #243311 @ 2019-02-08T07:57:50.500 signed by eosio [trxs: 0, lib: 243310, confirmed: 0]
info  2019-02-08T07:57:51.000 thread-0  producer_plugin.cpp:1549      produce_block        ] Produced block 0003b670c1a0556c... #243312 @ 2019-02-08T07:57:51.000 signed by eosio [trxs: 0, lib: 243311, confirmed: 0]
info  2019-02-08T07:57:51.505 thread-0  producer_plugin.cpp:1549      produce_block        ] Produced block 0003b6715d6f6874... #243313 @ 2019-02-08T07:57:51.500 signed by eosio [trxs: 0, lib: 243312, confirmed: 0]
info  2019-02-08T07:57:52.001 thread-0  producer_plugin.cpp:1549      produce_block        ] Produced block 0003b672522943cc... #243314 @ 2019-02-08T07:57:52.000 signed by eosio [trxs: 0, lib: 243313, confirmed: 0]

```
※ブロック番号などの情報は環境によって異なる．

##3.コマンドエイリアスを作成． 
cleos(cli+eos=cleos)

```
alias cleos='docker exec -it eosphi /opt/eosio/bin/cleos --url http://127.0.0.1:7777 --wallet-url http://127.0.0.1:5555'
```

##4.ウォレットを作成し管理．
*がついているとアンロック状態

```
$ cleos wallet create --to-console
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JC2vfyQBnWHU7oKJTj6fmjSpjDnsyqhS1nkiLMcEnHA2HN6wG7"

$ cleos wallet list
Wallets:
[
  "default *"
]
// 名前指定してウォレット作成
$ cleos wallet create -n phi --to-console
Creating wallet: phi
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JC3qDZYNTtnXSTgZjQaEUkBMLAWvSrvsRMbDhKYevYZq1ERx2s"
```

ウォレットの管理

```
// ウォレットを全てロック
$ cleos wallet lock_all
Locked All Wallets
// パスワードを入れてあげるとそのウォレットをアンロック
$ cleos wallet unlock
password: Unlocked: default
// アンロック状態のアカウントのみ*がつく
$ cleos wallet list
Wallets:
[
  "default *",
  "phi"
]
```
以上で「Dockerを用いたEOS開発環境の作成」を行いました．

今回はここまでとなります！
お疲れ様でした！