Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
FROM node:8-slim
MAINTAINER James Lovejoy <jameslovejoy1@gmail.com>
LABEL maintainer James Lovejoy <jameslovejoy1@gmail.com>

RUN apt update && apt install -y git build-essential python

RUN adduser vertcore
RUN adduser vertcore -u 9000
RUN mkdir /data && chown vertcore:vertcore -R /data
RUN mkdir /app && chown vertcore:vertcore -R /app
COPY vertcore-node.json /data/vertcore-node.json

USER vertcore
WORKDIR /home/vertcore
ADD run.sh /home/vertcore/run.sh

RUN /home/vertcore/run.sh clone
RUN /home/vertcore/run.sh install
# install vertcore
RUN npm config set prefix /app
RUN npm install --production -g vertcoin-project/vertcore

CMD ["/home/vertcore/vertcore/bin/vertcored"]
# run vertcore node
EXPOSE 3001
CMD ["/app/bin/vertcored", "-c", "/data"]
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Docker Image for Vertcoin Insight
[![Docker Pulls](https://img.shields.io/docker/pulls/jamesl22/insight-vtc.svg)](https://hub.docker.com/r/jamesl22/insight-vtc/)

## Quickstart
You can run the image directly using the ```docker run``` command.

The vertcore node will download the full blockchain which can take several hours, so you may want to mount the image's ```/data``` directory to a volume so that the data can be persisted when the node is restarted.

The following commands will persist data into ```~/.vertcore``` on the host machine:

```bash
$ docker run -v "~/.vertcore:/data" jamesl22/insight-vtc
```

### Configuration
The image will automatically create a default configuration file in the mounted ```/data``` directory. To make it easier to configure the node yourself you may want to directly mount the included ```vertcore-node.json``` file:
```bash
$ docker run -v "~/.vertcore:/data" -v "$(pwd)/vertcore-node.json:/data/vertcore-node.json" jamesl22/insight-vtc
```

If you want to run a testnet node you can mount the provided testnet configuration file instead:
```bash
$ docker run -v "~/.vertcore:/data" -v "$(pwd)/vertcore-node-testnet.json:/data/vertcore-node.json" jamesl22/insight-vtc
```

If you choose note to mount the ```vertcore-node.json``` file then you will have to manually edit the file from your mounted ```/data``` directory.

## Swarm Mode
The provided ```docker-compose-*``` files can be used to run a Vertcoin Insight node in swarm mode. There are three different variants:

| variant | compose file names | description |
|-|-|-|
| basic | ```docker-compose.yml```<br>```docker-compose-testnet.yml``` | A basic Insight node. |
| vcoin | ```docker-compose-vcoin.yml```<br>```docker-compose-vcoin-testnet.yml``` | Enables support for scaling to multiple Insight node instances, using [traefik](https://traefik.io/) as the loader balancer. |
| vertcoin | ```docker-compose-vertcoind.yml```<br>```docker-compose-vertcoind-testnet.yml``` | Enables support for scaling to multiple Insight node instances, using [traefik](https://traefik.io/) as the loader balancer. Also uses a shared ```vertcoind``` node to reduce the resources needed for each Insight node. |

Select the configuration you want to use and deploy using the following commands:
```bash
$ docker swarm init
$ docker stack deploy -c docker-compose-vertcoind.yml insight
```

Each variant includes a ```*-testnet.yml``` file. Deploy this configuration if you want your node to run against the test network.

## Building
This image has been published under the name ```jamesl22/insight-vtc```. You can build your own image using the ```docker build``` command:

```bash
$ docker build -t insight-vtc .
```

## Known Issues
### "Network mismatch" error after switching network
When switching a running node between live and test network you may need to delete the ```chain.ldb``` directory in the mounted ```/data``` volume. You may also wish to delete ```vertcorenode.db``` to reclaim disk space.

### Permission error writing to ```/data``` volume
When using ```docker run``` to run Insight you may need to ensure that the ```vertcore``` user has permission to write to the directory you have mounted to ```/data```. The ```vertcore``` user has a fixed UID of 9000 so you can use the following commands to prepare a suitable ```~/.vertcore``` directory:
```bash
$ mkdir ~/.vertcore
$ chown 9000 ~/.vertcore
```
20 changes: 20 additions & 0 deletions docker-compose-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# docker compose file for vertcore/insight
# this variant runs a single self-contained node
# - health checking (note: may cause problems during initial sync)
# - data persisted to docker volume
# - its own vcoin instance to sync to network
# - no scaling / load balancing
version: "3.4"
services:
insight:
image: jamesl22/insight-vtc
ports:
- "3001:80"
healthcheck:
test: curl -f http://localhost:3001/insight-vtc-api/status
start_period: 300s
volumes:
- vertcore:/data
- ${PWD}/vertcore-node-testnet.json:/data/vertcore-node.json
volumes:
vertcore:
44 changes: 44 additions & 0 deletions docker-compose-vcoin-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# docker compose file for vertcore/insight
# this variant runs multiple nodes that sync from self-contained vcoin nodes
# - health checking (note: may cause problems during initial sync)
# - data persisted to docker volume
# - each node runs its own vcoin instance to sync to network
# - supports scaling (default: 5 nodes)
# - load balances using traefik (sticky sessions required for socket.io)
version: "3.4"
services:
insight:
image: jamesl22/insight-vtc
deploy:
replicas: 5
labels:
traefik.port: "3001"
traefik.frontend.rule: "PathPrefix:/;"
traefik.backend.loadbalancer.sticky: "true"
networks:
- insight
healthcheck:
test: curl -f http://localhost:3001/insight-vtc-api/status
start_period: 300s
volumes:
- vertcore:/data
- ${PWD}/vertcore-node-testnet.json:/data/vertcore-node.json
loadbalancer:
image: traefik
command: --docker --docker.swarmmode --docker.watch --web --loglevel=DEBUG
ports:
- "80:80"
- "9090:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
placement:
constraints:
- node.role == manager
networks:
- insight
networks:
insight:
volumes:
vertcore:
name: '{{.Service.Name}}.{{.Task.Slot}}'
44 changes: 44 additions & 0 deletions docker-compose-vcoin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# docker compose file for vertcore/insight
# this variant runs multiple nodes that sync from self-contained vcoin nodes
# - health checking (note: may cause problems during initial sync)
# - data persisted to docker volume
# - each node runs its own vcoin instance to sync to network
# - supports scaling (default: 5 nodes)
# - load balances using traefik (sticky sessions required for socket.io)
version: "3.4"
services:
insight:
image: jamesl22/insight-vtc
deploy:
replicas: 5
labels:
traefik.port: "3001"
traefik.frontend.rule: "PathPrefix:/;"
traefik.backend.loadbalancer.sticky: "true"
networks:
- insight
healthcheck:
test: curl -f http://localhost:3001/insight-vtc-api/status
start_period: 300s
volumes:
- vertcore:/data
- ${PWD}/vertcore-node.json:/data/vertcore-node.json
loadbalancer:
image: traefik
command: --docker --docker.swarmmode --docker.watch --web --loglevel=DEBUG
ports:
- "80:80"
- "9090:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
placement:
constraints:
- node.role == manager
networks:
- insight
networks:
insight:
volumes:
vertcore:
name: '{{.Service.Name}}.{{.Task.Slot}}'
62 changes: 62 additions & 0 deletions docker-compose-vertcoind-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# docker compose file for vertcore/insight
# this variant runs multiple nodes that sync from a shared vertcoind instance
# - health checking
# - data persisted to docker volume
# - each node connects to a shared vertcoind service to sync to network
# - supports scaling (default: 5 nodes)
# - load balances using traefik (sticky sessions required for socket.io)
version: "3.4"
services:
insight:
image: jamesl22/insight-vtc
deploy:
replicas: 5
labels:
traefik.port: "3001"
traefik.frontend.rule: "PathPrefix:/;"
traefik.backend.loadbalancer.sticky: "true"
networks:
- insight
depends_on:
- vertcoind
healthcheck:
test: curl -f http://localhost:3001/insight-vtc-api/status
start_period: 300s
volumes:
- vertcore:/data
- ${PWD}/vertcore-node-vertcoind-testnet.json:/data/vertcore-node.json
vertcoind:
image: lukechilds/vertcoind
deploy:
placement:
constraints:
- node.role == manager
ports:
- "5888:5888"
- "5889:5889"
- "8332:8332"
volumes:
- vertcoind:/data
command: -rpcuser=middleware -rpcpassword=middleware -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -rpcport=8332 --testnet
networks:
- insight
loadbalancer:
image: traefik
command: --docker --docker.swarmmode --docker.watch --web --loglevel=DEBUG
ports:
- "80:80"
- "9090:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
placement:
constraints:
- node.role == manager
networks:
- insight
networks:
insight:
volumes:
vertcore:
name: '{{.Service.Name}}.{{.Task.Slot}}'
vertcoind:
62 changes: 62 additions & 0 deletions docker-compose-vertcoind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# docker compose file for vertcore/insight
# this variant runs multiple nodes that sync from a shared vertcoind instance
# - health checking
# - data persisted to docker volume
# - each node connects to a shared vertcoind service to sync to network
# - supports scaling (default: 5 nodes)
# - load balances using traefik (sticky sessions required for socket.io)
version: "3.4"
services:
insight:
image: jamesl22/insight-vtc
deploy:
replicas: 5
labels:
traefik.port: "3001"
traefik.frontend.rule: "PathPrefix:/;"
traefik.backend.loadbalancer.sticky: "true"
networks:
- insight
depends_on:
- vertcoind
healthcheck:
test: curl -f http://localhost:3001/insight-vtc-api/status
start_period: 300s
volumes:
- vertcore:/data
- ${PWD}/vertcore-node-vertcoind.json:/data/vertcore-node.json
vertcoind:
image: lukechilds/vertcoind
deploy:
placement:
constraints:
- node.role == manager
ports:
- "5888:5888"
- "5889:5889"
- "8332:8332"
volumes:
- vertcoind:/data
command: -rpcuser=middleware -rpcpassword=middleware -rpcallowip=0.0.0.0/0 -rpcbind=0.0.0.0 -rpcport=8332
networks:
- insight
loadbalancer:
image: traefik
command: --docker --docker.swarmmode --docker.watch --web --loglevel=DEBUG
ports:
- "80:80"
- "9090:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
placement:
constraints:
- node.role == manager
networks:
- insight
networks:
insight:
volumes:
vertcore:
name: '{{.Service.Name}}.{{.Task.Slot}}'
vertcoind:
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# docker compose file for vertcore/insight
# this variant runs a single self-contained node
# - health checking (note: may cause problems during initial sync)
# - data persisted to docker volume
# - its own vcoin instance to sync to network
# - no scaling / load balancing
version: "3.4"
services:
insight:
image: jamesl22/insight-vtc
ports:
- "3001:80"
healthcheck:
test: curl -f http://localhost:3001/insight-vtc-api/status
start_period: 300s
volumes:
- vertcore:/data
- ${PWD}/vertcore-node.json:/data/vertcore-node.json
volumes:
vertcore:
Loading