Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI and Publish workflows with GitHub Actions #209

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches:
- master
- feature/*
- bugfix/*
- develop
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20.x"
- run: npm ci
- run: USE_DOCKER=1 npm run test
38 changes: 38 additions & 0 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Publish

on:
release:
types: [created]

jobs:
# Publish mainnet-js package on npm
# Requires NPM_TOKEN github secret to be set
publish-npm:
runs-on: ubuntu-latest
steps:
# Build project
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build_commonjs && npm run build_web_worker

# Setup environment
- name: Check if NPM_TOKEN is set
run: |
if [ -n $NPM_TOKEN ]; then HAS_NPM_TOKEN='true' ; fi
echo "HAS_NPM_TOKEN=${HAS_NPM_TOKEN}" >> $GITHUB_ENV

# Actual job
- if: env.HAS_NPM_TOKEN == false
run: echo "NPM_TOKEN secret not set, skipping publishing"
- if: env.HAS_NPM_TOKEN
name: Publish to npm
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test_products
/test_wallets/
/build
/browser_build/
/dist/src/test/
/dist/src/test/
.localnet
2 changes: 1 addition & 1 deletion dist/dist/monero_web_worker.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/monero_web_worker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/monero_web_worker.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/src/main/ts/daemon/MoneroDaemonRpc.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/src/main/ts/wallet/MoneroWalletFull.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.7'
services:
monerod:
image: mainnetpat/monerod:v0.18.3.2
entrypoint: [""]
user: root
command: monerod --testnet --log-level=0 --no-igd --fixed-difficulty=1 --data-dir .localnet/xmr_local/node1 --disable-rpc-ban --db-sync-mode=safe --no-zmq --non-interactive --rpc-bind-ip=0.0.0.0 --rpc-bind-port=28081 --p2p-bind-ip=0.0.0.0 --p2p-bind-port=28080 --confirm-external-bind --rpc-ssl=disabled --rpc-access-control-origins="*" --add-exclusive-node monerod-peer:48080 --allow-local-ip
ports:
- '127.0.0.1:28081:28081'
restart: unless-stopped
volumes:
- ./.localnet:/home/monero/.localnet

monerod-peer:
image: mainnetpat/monerod:v0.18.3.2
entrypoint: [""]
user: root
command: monerod --testnet --log-level=0 --no-igd --fixed-difficulty=1 --data-dir .localnet/xmr_local/node2 --disable-rpc-ban --db-sync-mode=safe --no-zmq --non-interactive --rpc-bind-ip=0.0.0.0 --rpc-bind-port=48081 --p2p-bind-ip=0.0.0.0 --p2p-bind-port=48080 --confirm-external-bind --rpc-ssl=disabled --rpc-access-control-origins="*" --add-exclusive-node monerod:28080 --allow-local-ip
ports:
- '127.0.0.1:48081:48081'
restart: unless-stopped
volumes:
- ./.localnet:/home/monero/.localnet

monero-wallet-rpc:
image: mainnetpat/monerod:v0.18.3.2
entrypoint: [""]
user: root
command: monero-wallet-rpc --testnet --daemon-host=monerod --daemon-port=28081 --trusted-daemon --disable-rpc-ban --rpc-bind-ip=0.0.0.0 --rpc-bind-port=28084 --rpc-login=rpc_user:abc123 --confirm-external-bind --non-interactive --rpc-ssl=disabled --daemon-ssl=disabled --wallet-dir ./.localnet --rpc-access-control-origins="*"
ports:
- '127.0.0.1:28084:28084'
volumes:
- ./.localnet:/home/monero/.localnet
restart: unless-stopped
197 changes: 197 additions & 0 deletions docker/simple-monerod/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
# Initial base from https://github.com/leonardochaia/docker-monerod/blob/master/src/Dockerfile
# Alpine specifics from https://github.com/cornfeedhobo/docker-monero/blob/f96711415f97af1fc9364977d1f5f5ecd313aad0/Dockerfile

# Set Monero branch or tag to build
ARG MONERO_BRANCH=v0.18.3.2

# Set the proper HEAD commit hash for the given branch/tag in MONERO_BRANCH
ARG MONERO_COMMIT_HASH=ef3e18b51beb937c7f786ecef0d0a0e3f6295082

# Select Alpine 3.x for the build image base
FROM alpine:3.16 as build
LABEL author="seth@sethforprivacy.com" \
maintainer="seth@sethforprivacy.com"

# Upgrade base image
RUN set -ex && apk --update --no-cache upgrade

# Install all dependencies for a static build
RUN set -ex && apk add --update --no-cache \
autoconf \
automake \
boost \
boost-atomic \
boost-build \
boost-build-doc \
boost-chrono \
boost-container \
boost-context \
boost-contract \
boost-coroutine \
boost-date_time \
boost-dev \
boost-doc \
boost-fiber \
boost-filesystem \
boost-graph \
boost-iostreams \
boost-libs \
boost-locale \
boost-log \
boost-log_setup \
boost-math \
boost-prg_exec_monitor \
boost-program_options \
boost-python3 \
boost-random \
boost-regex \
boost-serialization \
boost-stacktrace_basic \
boost-stacktrace_noop \
boost-static \
boost-system \
boost-thread \
boost-timer \
boost-type_erasure \
boost-unit_test_framework \
boost-wave \
boost-wserialization \
ca-certificates \
cmake \
curl \
dev86 \
doxygen \
eudev-dev \
file \
g++ \
git \
graphviz \
libexecinfo-dev \
libsodium-dev \
libtool \
libusb-dev \
linux-headers \
make \
miniupnpc-dev \
ncurses-dev \
openssl-dev \
pcsc-lite-dev \
pkgconf \
protobuf-dev \
rapidjson-dev \
readline-dev \
zeromq-dev

# Set necessary args and environment variables for building Monero
ARG MONERO_BRANCH
ARG MONERO_COMMIT_HASH
ARG NPROC
ARG TARGETARCH
ENV CFLAGS='-fPIC'
ENV CXXFLAGS='-fPIC -DELPP_FEATURE_CRASH_LOG'
ENV USE_SINGLE_BUILDDIR 1
ENV BOOST_DEBUG 1

# Build expat, a dependency for libunbound
RUN set -ex && wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2 && \
echo "a247a7f6bbb21cf2ca81ea4cbb916bfb9717ca523631675f99b3d4a5678dcd16 expat-2.4.8.tar.bz2" | sha256sum -c && \
tar -xf expat-2.4.8.tar.bz2 && \
rm expat-2.4.8.tar.bz2 && \
cd expat-2.4.8 && \
./configure --enable-static --disable-shared --prefix=/usr && \
make -j${NPROC:-$(nproc)} && \
make -j${NPROC:-$(nproc)} install

# Build libunbound for static builds
WORKDIR /tmp
RUN set -ex && wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.16.1.tar.gz && \
echo "2fe4762abccd564a0738d5d502f57ead273e681e92d50d7fba32d11103174e9a unbound-1.16.1.tar.gz" | sha256sum -c && \
tar -xzf unbound-1.16.1.tar.gz && \
rm unbound-1.16.1.tar.gz && \
cd unbound-1.16.1 && \
./configure --disable-shared --enable-static --without-pyunbound --with-libexpat=/usr --with-ssl=/usr --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only --with-pic && \
make -j${NPROC:-$(nproc)} && \
make -j${NPROC:-$(nproc)} install

# Switch to Monero source directory
WORKDIR /monero

COPY core_rpc_server.cpp.patch /tmp/core_rpc_server.cpp.patch

# Git pull Monero source at specified tag/branch and compile statically-linked monerod binary
RUN set -ex && git clone --recursive --branch ${MONERO_BRANCH} \
--depth 1 --shallow-submodules \
https://github.com/monero-project/monero . \
&& git apply /tmp/core_rpc_server.cpp.patch \
&& test `git rev-parse HEAD` = ${MONERO_COMMIT_HASH} || exit 1 \
&& case ${TARGETARCH:-amd64} in \
"arm64") CMAKE_ARCH="armv8-a"; CMAKE_BUILD_TAG="linux-armv8" ;; \
"amd64") CMAKE_ARCH="x86-64"; CMAKE_BUILD_TAG="linux-x64" ;; \
*) echo "Dockerfile does not support this platform"; exit 1 ;; \
esac \
&& mkdir -p build/release && cd build/release \
&& cmake -D ARCH=${CMAKE_ARCH} -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG=${CMAKE_BUILD_TAG} ../.. \
&& cd /monero && nice -n 19 ionice -c2 -n7 make -j${NPROC:-$(nproc)} -C build/release daemon wallet_rpc_server simplewallet

# Begin final image build
# Select Alpine 3.x for the base image
FROM alpine:3.16

# Upgrade base image
RUN set -ex && apk --update --no-cache upgrade

# Install all dependencies for static binaries + curl for healthcheck
RUN set -ex && apk add --update --no-cache \
curl \
ca-certificates \
libexecinfo \
libsodium \
ncurses-libs \
pcsc-lite-libs \
readline \
tzdata \
zeromq

# Add user and setup directories for monerod
RUN set -ex && adduser -Ds /bin/bash monero \
&& mkdir -p /home/monero/.bitmonero \
&& chown -R monero:monero /home/monero/.bitmonero

# Copy and enable entrypoint script
ADD entrypoint.sh /entrypoint.sh
RUN set -ex && chmod +x entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]

# Install and configure fixuid and switch to MONERO_USER
ARG MONERO_USER="monero"
ARG TARGETARCH
RUN set -ex && case ${TARGETARCH:-amd64} in \
"arm64") curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.5.1/fixuid-0.5.1-linux-arm64.tar.gz | tar -C /usr/local/bin -xzf - ;; \
"amd64") curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.5.1/fixuid-0.5.1-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - ;; \
*) echo "Dockerfile does not support this platform"; exit 1 ;; \
esac && \
chown root:root /usr/local/bin/fixuid && \
chmod 4755 /usr/local/bin/fixuid && \
mkdir -p /etc/fixuid && \
printf "user: ${MONERO_USER}\ngroup: ${MONERO_USER}\n" > /etc/fixuid/config.yml
USER "${MONERO_USER}:${MONERO_USER}"

# Switch to home directory and install newly built monerod binary
WORKDIR /home/${MONERO_USER}
COPY --chown=monero:monero --from=build \
/monero/build/release/bin/monerod \
/monero/build/release/bin/monero-wallet-rpc \
/monero/build/release/bin/monero-wallet-cli \
/usr/local/bin/

# Expose p2p port
EXPOSE 18080

# Expose restricted RPC port
EXPOSE 18089

# Add HEALTHCHECK against get_info endpoint
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://localhost:18081/get_info || exit 1

# Start monerod with sane defaults that are overridden by user input (if applicable)
CMD ["--rpc-restricted-bind-ip=0.0.0.0", "--rpc-restricted-bind-port=18089", "--no-igd", "--no-zmq", "--enable-dns-blocklist"]
21 changes: 21 additions & 0 deletions docker/simple-monerod/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Seth Simmons (@sethsimmons)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.