This repository has been archived by the owner on Aug 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Showing
66 changed files
with
4,025 additions
and
1,869 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
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,74 @@ | ||
## Quickstart | ||
|
||
Run the official iotaledger/iri container, passing the mandatory -p option: | ||
|
||
```docker run iotaledger/iri:v1.5.0 -p 14265``` | ||
|
||
This will get your a running IRI with its API listening on port 14265, no neighbours and an empty database. The IRI Docker container by default expects data at /iri/data. Use the `-v` option of the `docker run` command to mount volumes so to have persistent data. You can also pass more command line options to the docker run command and those will be passed to IRI. | ||
|
||
If you want to use a iri.ini file with the docker container, supposing it's stored under /path/to/conf/iri.ini on your docker host, then pass `-v /path/to/conf:/iri/conf` and add -c /iri/conf/iri.ini as docker run arguments. So for example the `docker run` command above would become: | ||
|
||
```docker run -v /path/to/conf:/iri/conf -v /path/to/data:/iri/data iotaledger/iri:v1.5.0 -p 14265 -c /iri/conf/iri.ini``` | ||
|
||
Please refer to the IRI documentation for further command line options and iri.ini options. | ||
|
||
## DOCKER and IRI in depth | ||
|
||
The Dockerfile included in this repo builds a working IRI docker container whilst trying to stay the least opinionated as possible. This allows system administrators the option to deploy and configure IRI based on their own individual circumstances and needs. | ||
|
||
When building IRI via the Dockerfile provided, Docker 17.05 minimum is required, due to the use of Docker build stages. During docker build, these are the stages invoked: | ||
- java: installs Oracle Java on top of Ubuntu | ||
- build: installs Maven on top of the java stage and compiles IRI | ||
- final container: copies the IRI jar file using the java stage as base | ||
|
||
The built container assumes the WORKDIR inside the container is /iri/data: this means that the database directory will be written inside that directory by default. If a system administrator wants to retain the database across restarts, it is his/her job to mount a docker volume in the right folder. | ||
|
||
The docker conatiner supports the env variables to configure advanced options. These variables can be set but are not required to run IRI. | ||
|
||
`JAVA_OPTIONS`: these are the java options to pass right after the java command. It must not contain -Xms nor -Xmx. Defaults to a safe value | ||
`JAVA_MIN_MEMORY`: the value of -Xms option. Defaults to 2G | ||
`JAVA_MAX_MEMORY`: the value of -Xmx option. Defaults to 4G | ||
`DOCKER_IRI_JAR_PATH`: defaults to /iri/target/iri*.jar as pushed by the Dockerfile. This is useful if custom IRI binaries want to be executed and the default path needs to be overridden | ||
`DOCKER_IRI_REMOTE_LIMIT_API`: defaults to "interruptAttachToTangle, attachToTangle, addNeighbors, removeNeighbors, getNeighbors" | ||
`DOCKER_IRI_MONITORING_API_PORT_ENABLE`: defaults to 0. If set to 1, a socat on port 14266 directed to 127.0.0.1:DOCKER_IRI_MONITORING_API_PORT_DESTINATION will be open in order to allow all API calls regardless of the DOCKER_IRI_REMOTE_LIMIT_API setting. This is useful to give access to restricted API calls to local tools and still denying access to restricted API calls to the internet. It is highly recommended to use this option together with docker networks (docker run --net). | ||
|
||
The container entry point is a shell script that performs few additional steps before launching IRI: | ||
- verifies if `DOCKER_IRI_MONITORING_API_PORT_ENABLE` is set to 1 | ||
- launches IRI with all parameters passed as desired | ||
|
||
It is important to note that other than --remote and --remote-limit-api "$DOCKER_IRI_REMOTE_LIMIT_API", neither the entrypoint nor the Dockerfile are aware of any IRI configuration option. This is to not tie the Dockerfile and its container to a specific set of IRI options. Instead, this contain still allows the use of an INI file or command line options. Please refer to the IRI documentation to learn what are the allowed options at command line and via the INI file. | ||
|
||
**At the time of writing, IRI requires -p to be passed either via INI or via command line. The entrypoint of this docker container does not do that for you.** | ||
|
||
Here is a systemd unit example you can use with this Docker container. This is just an example and customisation is possible and recommended. In this example the docker network iri must be created and the paths /mnt/iri/conf and /mnt/iri/data are used on the docker host to serve respectively the neighbors file and the data directory. No INI files are used in this example, instead options are passed via command line options, such as --testnet and --zmq-enabled. | ||
|
||
``` | ||
[Unit] | ||
Description=IRI | ||
After=docker.service | ||
Requires=docker.service | ||
[Service] | ||
TimeoutStartSec=0 | ||
Restart=always | ||
ExecStartPre=-/usr/bin/docker rm %n | ||
ExecStart=/usr/bin/docker run \ | ||
--name %n \ | ||
--hostname iri \ | ||
--net=iri \ | ||
-v /mnt/iri/conf:/iri/conf \ | ||
-v /mnt/iri/data:/iri/data \ | ||
-p 14265:14265 \ | ||
-p 15600:15600 \ | ||
-p 14600:14600/udp \ | ||
iotaledger/iri:v1.5.0 \ | ||
-p 14265 \ | ||
--zmq-enabled \ | ||
--testnet | ||
ExecStop=/usr/bin/docker stop %n | ||
ExecReload=/usr/bin/docker restart %n | ||
[Install] | ||
WantedBy=multi-user.target | ||
``` |
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,16 +1,84 @@ | ||
FROM maven:3.5-jdk-8 as builder | ||
FROM ubuntu:18.04 as local_stage_java | ||
MAINTAINER [email protected] | ||
|
||
# Install Java | ||
ARG JAVA_VERSION=8u171-1 | ||
RUN \ | ||
apt-get update && \ | ||
apt-get install -y software-properties-common --no-install-recommends && \ | ||
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \ | ||
add-apt-repository -y ppa:webupd8team/java && \ | ||
apt-get update && \ | ||
apt-get install -y oracle-java8-installer=${JAVA_VERSION}~webupd8~0 --no-install-recommends && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
rm -rf /var/cache/oracle-jdk8-installer | ||
|
||
# Define commonly used JAVA_HOME variable | ||
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle | ||
|
||
# install maven on top of java stage | ||
FROM local_stage_java as local_stage_build | ||
ARG MAVEN_VERSION=3.5.3 | ||
ARG USER_HOME_DIR="/root" | ||
ARG SHA=b52956373fab1dd4277926507ab189fb797b3bc51a2a267a193c931fffad8408 | ||
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ | ||
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ | ||
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha256sum -c - \ | ||
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ | ||
&& rm -f /tmp/apache-maven.tar.gz \ | ||
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn | ||
|
||
ENV MAVEN_HOME /usr/share/maven | ||
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" | ||
|
||
COPY docker/mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh | ||
COPY docker/settings-docker.xml /usr/share/maven/ref/ | ||
|
||
VOLUME "$USER_HOME_DIR/.m2" | ||
|
||
# install build dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /iri | ||
|
||
COPY . /iri | ||
RUN mvn clean package | ||
|
||
FROM openjdk:jre-slim | ||
WORKDIR /iri | ||
COPY --from=builder /iri/target/iri-1.4.2.4.jar iri.jar | ||
COPY logback.xml /iri | ||
VOLUME /iri | ||
# execution image | ||
FROM local_stage_java | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
jq curl socat \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=local_stage_build /iri/target/iri*.jar /iri/target/ | ||
COPY docker/entrypoint.sh / | ||
|
||
# Java related options. Defaults set as below | ||
ENV JAVA_OPTIONS="-XX:+UnlockExperimentalVMOptions -XX:+DisableAttachMechanism -XX:InitiatingHeapOccupancyPercent=60 -XX:G1MaxNewSizePercent=75 -XX:MaxGCPauseMillis=10000 -XX:+UseG1GC" | ||
ENV JAVA_MIN_MEMORY 2G | ||
ENV JAVA_MAX_MEMORY 4G | ||
|
||
# Additional custom variables. See DOCKER.md for details | ||
ENV DOCKER_IRI_JAR_PATH "/iri/target/iri*.jar" | ||
ENV DOCKER_IRI_REMOTE_LIMIT_API "interruptAttachToTangle, attachToTangle, addNeighbors, removeNeighbors, getNeighbors" | ||
|
||
EXPOSE 14265 | ||
EXPOSE 14777/udp | ||
EXPOSE 15777 | ||
# Setting this to 1 will have socat exposing 14266 and pointing it on | ||
# localhost. See /entrypoint.sh | ||
# !!! DO NOT DOCKER EXPOSE (-p) 14266 as the remote api settings | ||
# will not be applied on that port !!! | ||
# You also have to maintain $DOCKER_IRI_MONITORING_API_PORT_DESTINATION | ||
# based on the actual API port exposed via IRI | ||
ENV DOCKER_IRI_MONITORING_API_PORT_ENABLE 0 | ||
ENV DOCKER_IRI_MONITORING_API_PORT_DESTINATION 14265 | ||
|
||
CMD ["/usr/bin/java", "-XX:+DisableAttachMechanism", "-Xmx8g", "-Xms256m", "-Dlogback.configurationFile=/iri/conf/logback.xml", "-Djava.net.preferIPv4Stack=true", "-jar", "iri.jar", "-p", "14265", "-u", "14777", "-t", "15777", "--remote", "--remote-limit-api", "\"addNeighbors, removeNeighbors, getNeighbors\"", "$@"] | ||
WORKDIR /iri/data | ||
ENTRYPOINT [ "/entrypoint.sh" ] |
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,15 @@ | ||
#!/bin/bash | ||
# See Dockerfile and DOCKER.md for further info | ||
|
||
if [ "${DOCKER_IRI_MONITORING_API_PORT_ENABLE}" == "1" ]; then | ||
nohup socat -lm TCP-LISTEN:14266,fork TCP:127.0.0.1:${DOCKER_IRI_MONITORING_API_PORT_DESTINATION} & | ||
fi | ||
|
||
exec java \ | ||
$JAVA_OPTIONS \ | ||
-Xms$JAVA_MIN_MEMORY \ | ||
-Xmx$JAVA_MAX_MEMORY \ | ||
-Djava.net.preferIPv4Stack=true \ | ||
-jar $DOCKER_IRI_JAR_PATH \ | ||
--remote --remote-limit-api "$DOCKER_IRI_REMOTE_LIMIT_API" \ | ||
"$@" |
Oops, something went wrong.