Skip to content

Commit

Permalink
Adding docker
Browse files Browse the repository at this point in the history
  • Loading branch information
nuriel77 committed Dec 11, 2019
1 parent b9862c3 commit 6cc53f3
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
latest-export.gz.bin
37 changes: 37 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Quickstart

## Clone
To quickly build, first clone the repository

```sh
git clone https://github.com/gohornet/hornet && cd hornet
```

## Run build
```sh
docker build -t hornet:latest .
```

## Prepare

i. Download the DB file
```sh
curl -LO https://dbfiles.iota.org/mainnet/hornet/latest-export.gz.bin
```

ii. Create a directory for the database. You can choose any path (perferably on a partition with enough disk space):
```sh
mkdir /tmp/db
```
(Note: In the example above we're using /tmp that will get wiped after a reboot)

iii. Edit the `config.json` for neighbors and alternative ports if needed.


## Run

Best run on host network for better performance (otherwise you are going to have to publish ports, that is done via iptables NAT and is slower)
```sh
docker run --rm -v $(pwd)/config.json:/app/config.json:ro -v $(pwd)/latest-export.gz.bin:/app/latest-export.gz.bin:ro -v /tmp/db:/app/mainnetdb --name hornet --net=host hornet:latest
```
Use CTRL-c to gracefully end the process.
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ---[ build image ]---
FROM golang:1.13 as builder

WORKDIR /go/src/github.com/gohornet/hornet
ADD . .
RUN CGO_ENABLED=0 GOOS=linux go build -o ./hornet main.go

# ---[ runtime image ]---
FROM alpine:latest
WORKDIR /app
ENV TINI_VERSION v0.18.0

# Tini is excellent: https://github.com/krallin/tini#why-tini
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static.asc /tini.asc

COPY --from=builder ["/go/src/github.com/gohornet/hornet/hornet", "/go/src/github.com/gohornet/hornet/config.json", "/app/"]
RUN apk --no-cache add ca-certificates gnupg\
&& addgroup --gid 39999 hornet\
&& adduser -h /app -s /bin/sh -G hornet -u 39999 -D hornet\
&& chmod +x /tini /app/hornet\
&& chown hornet:hornet -R /app\
&& gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7\
&& gpg --batch --verify /tini.asc /tini

# Not exposing ports, as it might be more efficient to run this on host network because of performance gain.
# | Host mode networking can be useful to optimize performance, and in situations where a container needs
# | to handle a large range of ports, as it does not require network address translation (NAT), and no
# | “userland-proxy” is created for each port.
# Source: https://docs.docker.com/network/host/

USER hornet
ENTRYPOINT ["/tini", "--"]
CMD ["/app/hornet"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ This way, HORNET is easier to install and runs on low-end devices.
- Extract the files in a folder of your choice
- Add neighbors to the config.json file
- Download the latest HORNET snapshot from [dbfiles.iota.org](https://dbfiles.iota.org/mainnet/hornet/latest-export.gz.bin)
- Run HORNET: `./hornet -c config`
- Run HORNET: `./hornet -c config`

### Docker

See [Docker](DOCKER.md)

0 comments on commit 6cc53f3

Please sign in to comment.