This commit is contained in:
Artur
2025-03-25 17:00:12 -03:00
commit 0dc80c2fa1
2 changed files with 194 additions and 0 deletions

56
.github/workflows/publish.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
name: Create and publish a Docker image
on:
push:
tags:
- "*"
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: magicgrants/monero-lws
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

138
Dockerfile Normal file
View File

@@ -0,0 +1,138 @@
# Initial base from https://github.com/sethforprivacy/monero-lws/blob/588c7f1965d3afbda8a65dc870645650e063e897/Dockerfile
# Set monerod version to install from github
ARG MONERO_BRANCH=v0.18.3.4
ARG MONERO_COMMIT_HASH=b089f9ee69924882c5d14dd1a6991deb05d9d1cd
# Select ubuntu:20.04 for the build image base
FROM ubuntu:20.04 as build
# Install all dependencies for a static build
# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get upgrade --no-install-recommends -y
RUN apt-get install --no-install-recommends -y \
build-essential \
ca-certificates \
ccache \
cmake \
doxygen \
git \
graphviz \
libboost-all-dev \
libexpat1-dev \
libldns-dev \
liblzma-dev \
libpgm-dev \
libprotobuf-dev \
libreadline6-dev \
libsodium-dev \
libssl-dev \
libudev-dev \
libunwind8-dev \
libusb-1.0-0-dev \
libzmq3-dev \
pkg-config \
protobuf-compiler \
qttools5-dev-tools \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 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_6_3/expat-2.6.3.tar.bz2 && \
echo "b8baef92f328eebcf731f4d18103951c61fa8c8ec21d5ff4202fb6f2198aeb2d expat-2.6.3.tar.bz2" | sha256sum -c && \
tar -xf expat-2.6.3.tar.bz2 && \
rm expat-2.6.3.tar.bz2 && \
cd expat-2.6.3 && \
./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.22.0.tar.gz && \
echo "c5dd1bdef5d5685b2cedb749158dd152c52d44f65529a34ac15cd88d4b1b3d43 unbound-1.22.0.tar.gz" | sha256sum -c && \
tar -xzf unbound-1.22.0.tar.gz && \
rm unbound-1.22.0.tar.gz && \
cd unbound-1.22.0 && \
./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
# Git pull Monero source at specified tag/branch and compile monerod binary
RUN git clone --recursive --branch ${MONERO_BRANCH} \
https://github.com/monero-project/monero . \
&& test `git rev-parse HEAD` = ${MONERO_COMMIT_HASH} || exit 1 \
&& git submodule init && git submodule update \
&& mkdir -p build/release && cd build/release \
# Create make build files manually for release-static-linux-${TARGETARCH}
&& case ${TARGETARCH:-amd64} in \
"arm64") cmake -D STATIC=ON -D ARCH="armv8-a" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-armv8" ../.. ;; \
"amd64") cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release -D BUILD_TAG="linux-x64" ../.. ;; \
*) echo "Dockerfile does not support this platform"; exit 1 ;; \
esac \
# Build only monerod binary using number of available threads
&& cd /monero && nice -n 19 ionice -c2 -n7 make -j${NPROC:-$(nproc)} -C build/release daemon lmdb_lib multisig
# Switch to monero-lws source directory
WORKDIR /monero-lws
ARG LWS_RELEASE=release-v0.3_0.18
ARG NPROC
RUN set -ex \
&& git clone --branch ${LWS_RELEASE} https://github.com/vtnerd/monero-lws.git . \
&& rm -rf build && mkdir build && cd build \
&& cmake -D STATIC=ON -D MONERO_SOURCE_DIR=/monero -D MONERO_BUILD_DIR=/monero/build/release .. \
&& make -j${NPROC:-$(nproc)}
# Begin final image build
# Select Ubuntu 20.04LTS for the image base
FROM ubuntu:20.04
# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation
ENV DEBIAN_FRONTEND=noninteractive
# Upgrade base image
RUN apt-get update \
&& apt-get upgrade --no-install-recommends -y
# Install necessary dependencies
RUN apt-get install --no-install-recommends -y \
ca-certificates \
curl \
jq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add user and setup directories for monero-lws
RUN useradd -ms /bin/bash monero-lws \
&& mkdir -p /home/monero-lws/.bitmonero/light_wallet_server \
&& chown -R monero-lws:monero-lws /home/monero-lws/.bitmonero
USER monero-lws
# Switch to home directory and install newly built monero-lws binary
WORKDIR /home/monero-lws
COPY --chown=monero-lws:monero-lws --from=build /monero-lws/build/src/* /usr/local/bin/
# Expose REST server port
EXPOSE 8443
ENTRYPOINT ["monero-lws-daemon", "--db-path=/home/monero-lws/.bitmonero/light_wallet_server"]
CMD ["--daemon=tcp://monerod:18082", "--sub=tcp://monerod:18083", "--log-level=4"]