forked from iotaledger/hornet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Dockerfiles for armhf and arm64 (iotaledger#146)
- Loading branch information
Showing
14 changed files
with
283 additions
and
119 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,8 +1,9 @@ | ||
latest-export.gz.bin | ||
.github | ||
.git | ||
Dockerfile | ||
DOCKER.md | ||
docker/ | ||
mainnetdb/ | ||
snapshot/ | ||
README.md | ||
.dockerignore | ||
docker-compose.yml |
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 was deleted.
Oops, something went wrong.
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,121 @@ | ||
# Hornet in Docker | ||
|
||
*Table of contents* | ||
|
||
<!--ts--> | ||
* [Requirements](#requirements) | ||
* [Quick Start](#quick-start) | ||
* [Clone Repository](#clone-repository) | ||
* [Prepare](#prepare) | ||
* [Docker Compose](#docker-compose) | ||
* [Build Image](#build-image) | ||
* [Run](#run) | ||
* [Local Snapshots](#local-snapshots) | ||
* [Build Specific Version](#build-specific-version) | ||
<!--te--> | ||
|
||
## Requirements | ||
|
||
1. A recent release of Docker enterprise or community edition. | ||
|
||
2. git and curl | ||
|
||
3. At least 1GB available RAM | ||
|
||
## Quick Start | ||
|
||
### Clone Repository | ||
Clone the repository | ||
|
||
```sh | ||
git clone https://github.com/gohornet/hornet && cd hornet | ||
``` | ||
The rest of the document assumes you are executing commands from the root directory of the repository. | ||
|
||
### Prepare | ||
|
||
i. Download the DB file | ||
```sh | ||
curl -LO https://dbfiles.iota.org/mainnet/hornet/latest-export.gz.bin | ||
``` | ||
|
||
ii. Edit the `config.json` for alternative ports if needed. | ||
|
||
iii. Edit `neighbors.json` to your neighbors addresses. | ||
|
||
iv. The docker image runs under user with uid 39999. To make sure no permission issues, create the directory for the database, e.g.: | ||
```sh | ||
mkdir mainnetdb && chown 39999:39999 mainnetdb | ||
``` | ||
### Docker Compose | ||
|
||
Note: Follow this step only if you want to run Hornet via docker-compose. | ||
|
||
If you are using an architecture other than amd64/x86_64 edit the `docker-compose.yml` file and set the correct architecture where noted. | ||
|
||
The following command will build the image and run Hornet: | ||
```sh | ||
docker-compose up | ||
``` | ||
CTRL-c to stop. | ||
|
||
Add `-d` to run detached, and to stop: | ||
|
||
```sh | ||
docker-compose down -t 1200 | ||
``` | ||
|
||
### Build Image | ||
If not running via docker-compose, build the image manually: | ||
|
||
```sh | ||
docker build -f docker/Dockerfile -t hornet:latest . | ||
``` | ||
Or pull it from dockerhub (only available for amd64/x86_64): | ||
|
||
```sh | ||
docker pull gohornet/hornet:latest && docker tag gohornet/hornet:latest hornet:latest | ||
``` | ||
|
||
Note: for architectures other than amd64/x86_64 pass the corresponding Dockerfile, e.g.: | ||
```sh | ||
docker build -f docker/Dockerfile.arm64 -t hornet:latest . | ||
``` | ||
|
||
|
||
### Run | ||
|
||
Best is to 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 $(pwd)/mainnetdb:/app/mainnetdb --name hornet --net=host hornet:latest | ||
``` | ||
Use CTRL-c to gracefully end the process. | ||
|
||
## Local Snapshots | ||
|
||
Version `0.3.0` of Hornet introduced the local snapshots feature. To make sure it works well in Docker, follow these steps: | ||
|
||
Before you begin, make sure hornet is stopped. | ||
|
||
i. Create and download the latest-export to a separate directory: | ||
```sh | ||
mkdir -p snapshot\ | ||
&& curl -L -o snapshot/latest-export.gz.bin https://dbfiles.iota.org/mainnet/hornet/latest-export.gz.bin\ | ||
&& chown 39999:39999 snapshot -R | ||
``` | ||
|
||
ii. Edit `config.json` and set the correct path. This can be done using `sed`: | ||
```sh | ||
sed -i 's#"path": "latest-export.gz.bin"#"path": "snapshot/latest-export.gz.bin"#' config.json | ||
``` | ||
|
||
iii. To run docker you should mount the new `snapshot` directory with read-write mode. This allows Hornet to update the `latest-export.gz.bin` file: | ||
```sh | ||
docker run --rm -v $(pwd)/config.json:/app/config.json:ro -v $(pwd)/snapshot:/app/snapshot:rw -v $(pwd)/mainnetdb:/app/mainnetdb --name hornet --net=host hornet:latest | ||
``` | ||
|
||
## Build Specific Version | ||
By default the Dockerfile builds the image using Hornet's latest version. To build an image with a specific version you can pass it via the build argument `TAG`, e.g.: | ||
```sh | ||
docker build -f docker/Dockerfile -t hornet:v0.3.0 --build-arg TAG=v0.3.0 . | ||
``` |
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,47 @@ | ||
FROM alpine:latest | ||
|
||
ARG REPO="gohornet/hornet" | ||
ARG TAG=latest | ||
ARG ARCH=x86_64 | ||
ARG OS=Linux | ||
|
||
LABEL org.label-schema.description="HORNET - The IOTA community node" | ||
LABEL org.label-schema.name="gohornet/hornet" | ||
LABEL org.label-schema.schema-version="1.0" | ||
LABEL org.label-schema.vcs-url="https://github.com/gohornet/hornet" | ||
LABEL org.label-schema.usage="https://github.com/gohornet/hornet/blob/master/DOCKER.md" | ||
|
||
WORKDIR /app | ||
|
||
RUN apk --no-cache add curl jq tini tar\ | ||
&& if [ "$TAG" = "latest" ];\ | ||
then\ | ||
HORNET_TAG=$(curl --retry 3 -f -s https://api.github.com/repos/${REPO}/releases/latest | jq -r .tag_name | tr -d 'v');\ | ||
else\ | ||
HORNET_TAG="${TAG//v}";\ | ||
fi\ | ||
&& echo "Downloading from https://github.com/${REPO}/releases/download/v${HORNET_TAG}/HORNET-${HORNET_TAG}_${OS}_${ARCH}.tar.gz ..."\ | ||
&& curl -f -L --retry 3 "https://github.com/${REPO}/releases/download/v${HORNET_TAG}/HORNET-${HORNET_TAG}_${OS}_${ARCH}.tar.gz" -o /tmp/hornet.tgz\ | ||
&& tar --wildcards --strip-components=1 -xf /tmp/hornet.tgz -C /app/ */hornet */config.json */neighbors.json\ | ||
&& if [ "$ARCH" = "x86_64" ];\ | ||
then\ | ||
curl -f -L --retry 3 -o /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub;\ | ||
curl -f -L --retry 3 -o glibc-2.30-r0.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk;\ | ||
apk add glibc-2.30-r0.apk;\ | ||
rm glibc-2.30-r0.apk;\ | ||
fi\ | ||
&& addgroup --gid 39999 hornet\ | ||
&& adduser -h /app -s /bin/sh -G hornet -u 39999 -D hornet\ | ||
&& chmod +x /app/hornet\ | ||
&& chown hornet:hornet -R /app\ | ||
&& rm /tmp/hornet.tgz\ | ||
&& apk del jq curl | ||
|
||
# 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 ["/sbin/tini", "--", "/app/hornet"] |
Oops, something went wrong.