-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NODE-2256: Use the modern docker image for integration tests (#3346)
- Loading branch information
Showing
20 changed files
with
194 additions
and
297 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,18 @@ | ||
#!/bin/bash | ||
|
||
NETWORK="Mainnet" | ||
|
||
if [[ -n $1 ]]; then | ||
NETWORK=$1 | ||
fi | ||
|
||
echo "Building with network: $NETWORK" | ||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
USER=$(id -u) | ||
GROUP=$(id -g) | ||
|
||
docker run --mount type=bind,source="$DIR",target=/src -i mozilla/sbt:8u232_1.3.8 /bin/sh -c " | ||
cd /src && | ||
COURSIER_CACHE=\"$DIR/target/docker/coursier\" sbt \"-Dsbt.boot.directory=$DIR/target/docker/sbt_cache\" \"set ThisBuild/network := $NETWORK\" packageAll && | ||
chown -R $USER:$GROUP . | ||
" |
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 |
---|---|---|
@@ -1,81 +1,30 @@ | ||
FROM openjdk:8-jdk-stretch as builder | ||
ARG SBT_VERSION=1.2.8 | ||
ARG WAVES_VERSION="latest" | ||
ARG BRANCH="version-1.1.x" | ||
ARG DEB_PACKAGE_NETWORKS | ||
|
||
RUN \ | ||
{ \ | ||
WAVES_VERSION=$WAVES_VERSION && \ | ||
test $WAVES_VERSION = "latest" && \ | ||
WAVES_VERSION=$(curl -fsSL \ | ||
https://api.github.com/repos/wavesplatform/Waves/releases/latest \ | ||
| tac | grep -m 1 'tag_name.:' | tr -cd '[0-9\.]') && \ | ||
echo "Using latest version '${WAVES_VERSION}'" \ | ||
;} ; \ | ||
{ \ | ||
curl -fsSL https://api.github.com/repos/wavesplatform/Waves/releases \ | ||
| tac | grep -q "tag_name.*${WAVES_VERSION}" && \ | ||
echo "GitHub release '${WAVES_VERSION}' found" \ | ||
;} && \ | ||
{ \ | ||
echo "Downloading Waves '${WAVES_VERSION}' from GitHub" && \ | ||
mkdir -p /waves/node/target && \ | ||
releaseUrl="https://github.com/wavesplatform/Waves/releases/download" && \ | ||
\ | ||
echo "Downloading jar file" && \ | ||
curl -fL ${releaseUrl}/v${WAVES_VERSION}/waves-all-${WAVES_VERSION}.jar \ | ||
-o /waves/node/target/waves-all-${WAVES_VERSION}.jar \ | ||
;} || \ | ||
{ \ | ||
echo "Downloading sbt '${SBT_VERSION}'" && \ | ||
curl -fL -o sbt-$SBT_VERSION.deb \ | ||
https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \ | ||
dpkg -i sbt-$SBT_VERSION.deb && rm sbt-$SBT_VERSION.deb && \ | ||
git clone https://github.com/wavesplatform/Waves.git \ | ||
--branch $BRANCH waves && cd waves && \ | ||
git config --global user.name "Sbt Builder" && \ | ||
git config --global user.email "[email protected]" && \ | ||
git tag -a "v${WAVES_VERSION}" -m "Docker build" && \ | ||
SBT_OPTS="-Xmx2g -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m" \ | ||
sbt "node/assembly" && \ | ||
for network in $DEB_PACKAGE_NETWORKS ; do \ | ||
echo "Building '${network}' package" && \ | ||
SBT_OPTS="-XX:ReservedCodeCacheSize=128m \ | ||
-Xmx2g -Dnetwork=${network}" sbt 'packageAll' && \ | ||
mkdir -p /out/${network} && \ | ||
mv node/target/waves*.deb /out/${network}/ && \ | ||
cp node/target/waves-all*.jar /out/${network}/ && \ | ||
mv grpc-server/target/universal/grpc-server*.tgz /out/${network}/ && \ | ||
mv grpc-server/target/grpc-server*.deb /out/${network}/ ; \ | ||
done \ | ||
;} | ||
|
||
FROM openjdk:11-jre-slim | ||
ARG WAVES_VERSION="latest" | ||
FROM debian:stable-slim | ||
ARG WAVES_LOG_LEVEL="INFO" | ||
ARG WAVES_HEAP_SIZE="2g" | ||
ARG WAVES_NETWORK="mainnet" | ||
ARG ENABLE_GRPC="true" | ||
|
||
ENV WAVES_VERSION=$WAVES_VERSION | ||
ENV WAVES_LOG_LEVEL=$WAVES_LOG_LEVEL | ||
ENV WAVES_HEAP_SIZE=$WAVES_HEAP_SIZE | ||
ENV WAVES_NETWORK=$WAVES_NETWORK | ||
ENV ENABLE_GRPC=$ENABLE_GRPC | ||
|
||
COPY --from=builder /waves/node/target/waves-all-*.jar /usr/share/waves/lib/ | ||
COPY entrypoint.sh /usr/share/waves/bin/ | ||
COPY build-scripts /tmp/ | ||
|
||
RUN groupadd -g 143 waves && \ | ||
useradd -d /var/lib/waves -g 143 -u 143 -s /bin/bash -M waves && \ | ||
mkdir -p /var/lib/waves /etc/waves /usr/share/waves/lib/plugins && \ | ||
chown -R 143:143 /var/lib/waves /usr/share/waves /etc/waves && \ | ||
chmod -R 755 /var/lib/waves /usr/share/waves /etc/waves && \ | ||
ln -fs /var/lib/waves/log /var/log/waves | ||
# Additional dependencies | ||
RUN /bin/bash /tmp/setup-deps.sh | ||
|
||
WORKDIR /var/lib/waves | ||
EXPOSE 6869 6868 6863 6862 | ||
# Node DEB files | ||
ENV WVDATA=/var/lib/waves | ||
ENV WVLOG=/var/log/waves | ||
COPY target /tmp/ | ||
RUN /bin/bash /tmp/setup-node.sh | ||
|
||
USER waves | ||
EXPOSE 6869 6868 6863 6862 6870 | ||
VOLUME /var/lib/waves | ||
VOLUME /var/log/waves | ||
VOLUME /usr/share/waves/lib/plugins | ||
WORKDIR /var/lib/waves | ||
|
||
STOPSIGNAL SIGINT | ||
ENTRYPOINT ["/usr/share/waves/bin/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
shopt -s nullglob | ||
NETWORKS="mainnet testnet stagenet" | ||
|
||
logEcho() { | ||
echo $1 | gosu waves tee -a /var/log/waves/waves.log | ||
} | ||
|
||
mkdir -p $WVDATA $WVLOG | ||
chmod 700 $WVDATA $WVLOG || : | ||
|
||
user="$(id -u)" | ||
if [ "$user" = '0' ]; then | ||
find $WVDATA \! -user waves -exec chown waves '{}' + | ||
find $WVLOG \! -user waves -exec chown waves '{}' + | ||
fi | ||
|
||
[ -z "${WAVES_CONFIG}" ] && WAVES_CONFIG="/etc/waves/waves.conf" | ||
if [[ ! -f "$WAVES_CONFIG" ]]; then | ||
logEcho "Custom '$WAVES_CONFIG' not found. Using a default one for '${WAVES_NETWORK,,}' network." | ||
if [[ $NETWORKS == *"${WAVES_NETWORK,,}"* ]]; then | ||
touch "$WAVES_CONFIG" | ||
echo "waves.blockchain.type=${WAVES_NETWORK}" >>$WAVES_CONFIG | ||
|
||
sed -i 's/include "local.conf"//' "$WAVES_CONFIG" | ||
for f in /etc/waves/ext/*.conf; do | ||
echo "Adding $f extension config to waves.conf" | ||
echo "include required(\"$f\")" >>$WAVES_CONFIG | ||
done | ||
echo 'include "local.conf"' >>$WAVES_CONFIG | ||
else | ||
echo "Network '${WAVES_NETWORK,,}' not found. Exiting." | ||
exit 1 | ||
fi | ||
else | ||
echo "Found custom '$WAVES_CONFIG'. Using it." | ||
fi | ||
|
||
[ -n "${WAVES_WALLET_PASSWORD}" ] && JAVA_OPTS="${JAVA_OPTS} -Dwaves.wallet.password=${WAVES_WALLET_PASSWORD}" | ||
[ -n "${WAVES_WALLET_SEED}" ] && JAVA_OPTS="${JAVA_OPTS} -Dwaves.wallet.seed=${WAVES_WALLET_SEED}" | ||
JAVA_OPTS="${JAVA_OPTS} -Dwaves.data-directory=$WVDATA/data -Dwaves.directory=$WVDATA" | ||
|
||
logEcho "Node is starting..." | ||
logEcho "WAVES_HEAP_SIZE='${WAVES_HEAP_SIZE}'" | ||
logEcho "WAVES_LOG_LEVEL='${WAVES_LOG_LEVEL}'" | ||
logEcho "WAVES_NETWORK='${WAVES_NETWORK}'" | ||
logEcho "WAVES_WALLET_SEED='${WAVES_WALLET_SEED}'" | ||
logEcho "WAVES_WALLET_PASSWORD='${WAVES_WALLET_PASSWORD}'" | ||
logEcho "WAVES_CONFIG='${WAVES_CONFIG}'" | ||
logEcho "JAVA_OPTS='${JAVA_OPTS}'" | ||
|
||
JAVA_OPTS="-Dlogback.stdout.level=${WAVES_LOG_LEVEL} | ||
-XX:+ExitOnOutOfMemoryError | ||
-Xmx${WAVES_HEAP_SIZE} | ||
-Dlogback.file.directory=$WVLOG | ||
-Dconfig.override_with_env_vars=true | ||
${JAVA_OPTS} | ||
-cp '/usr/share/waves/lib/plugins/*:/usr/share/waves/lib/*'" exec gosu waves waves "$WAVES_CONFIG" |
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,10 @@ | ||
#!/bin/bash | ||
|
||
mkdir -p /usr/share/man/man1 | ||
apt-get update && apt-get install -y wget unzip default-jre-headless gosu || exit 1 | ||
|
||
YOURKIT_ARCHIVE="YourKit-JavaProfiler-2019.8-docker.zip" | ||
wget --quiet "https://www.yourkit.com/download/docker/$YOURKIT_ARCHIVE" -P /tmp/ && unzip /tmp/$YOURKIT_ARCHIVE -d /usr/local | ||
|
||
# Clean | ||
apt-get remove -y wget unzip && apt-get autoremove -y && apt-get autoclean && rm -rf /var/lib/apt/lists/* |
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,22 @@ | ||
#!/bin/bash | ||
|
||
# Create user | ||
groupadd -r waves --gid=999 | ||
useradd -r -g waves --uid=999 --home-dir=$WVDATA --shell=/bin/bash waves | ||
|
||
# Install DEB packages | ||
dpkg -i /tmp/waves.deb || exit 1 | ||
if [[ $ENABLE_GRPC == "true" ]]; then | ||
echo "Installing gRPC server" | ||
dpkg -i /tmp/grpc-server.deb || exit 1 | ||
fi | ||
|
||
# Set permissions | ||
chown -R waves:waves $WVDATA $WVLOG && chmod 777 $WVDATA $WVLOG | ||
|
||
rm /etc/waves/waves.conf # Remove example config | ||
cp /tmp/entrypoint.sh /usr/share/waves/bin/entrypoint.sh | ||
chmod +x /usr/share/waves/bin/entrypoint.sh | ||
|
||
# Cleanup | ||
rm -rf /tmp/* |
Oops, something went wrong.