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

Alpine based Multi-Stage Dockerfile #29

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [workflow_dispatch, push]

env:
IMAGE_NAME: monero
PLATFORMS: amd64 arm64/v8 arm/v7
PLATFORMS: amd64 arm64/v8

jobs:
build:
Expand All @@ -15,7 +15,6 @@ jobs:
include:
- platform: amd64
- platform: arm64/v8
- platform: arm/v7
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
Expand Down
90 changes: 55 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,75 @@
###################
# --- builder --- #
###################
FROM docker.io/debian:10-slim AS builder
FROM docker.io/alpine:3 AS builder

WORKDIR /opt

RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y build-essential \
cmake pkg-config libboost-all-dev \
libssl-dev libzmq3-dev libunbound-dev \
libsodium-dev libunwind8-dev liblzma-dev \
libreadline6-dev libldns-dev libexpat1-dev \
doxygen graphviz libpgm-dev qttools5-dev-tools \
libhidapi-dev libusb-1.0-0-dev libprotobuf-dev \
protobuf-compiler libudev-dev git && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN apk update \
&& apk upgrade \
&& apk add 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 unbound-dev zeromq-dev

ARG MONERO_VERSION=0.17.3.2
RUN git clone --recursive https://github.com/monero-project/monero.git -b v${MONERO_VERSION} --depth 1
RUN git clone --recursive --depth 1 --shallow-submodules https://github.com/monero-project/monero.git -b v${MONERO_VERSION}

ARG BUILD_THREADS=1
RUN cd monero && \
case "$(uname -m)" in \
x86_64) make -j${BUILD_THREADS} release-static-linux-x86_64;; \
aarch64* | arm64 | armv8*) make -j${BUILD_THREADS} release-static-linux-armv8;; \
armv7*) make -j${BUILD_THREADS} release-static-linux-armv7;; \
armv6*) make -j${BUILD_THREADS} release-static-linux-armv6;; \
*) echo "Unknown architecture: $(uname -m)" && exit 1;; \
esac
RUN cd monero \
&& case "$(uname -m)" in \
x86_64) CMAKE_ARCH="x86-64"; CMAKE_BUILD_TAG="linux-x64";; \
aarch64* | arm64 | armv8*) CMAKE_ARCH="armv8-a"; CMAKE_BUILD_TAG="linux-armv8";; \
*) echo "Unknown architecture: $(uname -m)" && 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 /opt/monero \
&& nice -n 19 ionice -c2 -n7 make -j${BUILD_THREADS} -C build/release


##################
# --- runner --- #
##################
FROM docker.io/debian:11-slim
FROM docker.io/alpine:3

ENV PATH=/opt/monero:${PATH}

RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y tini ca-certificates libkrb5-dev && \
apt-get clean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt && \
useradd -ms /bin/bash monero && \
mkdir /opt/bitmonero && \
ln -s /opt/bitmonero /home/monero/.bitmonero && \
chown -R monero:monero /home/monero/.bitmonero && \
chown -R monero:monero /opt/bitmonero

COPY --from=builder /opt/monero/build/Linux/_no_branch_/release/bin/* /opt/monero/
RUN apk --no-cache --update upgrade \
&& apk --no-cache add curl \
ca-certificates libexecinfo \
libsodium ncurses-libs \
pcsc-lite-libs readline \
unbound-dev zeromq tini \
&& addgroup monero \
&& adduser -D -h /home/monero -s /bin/sh -G monero monero \
&& mkdir /opt/bitmonero \
&& ln -s /opt/bitmonero /home/monero/.bitmonero \
&& chown -R monero:monero /home/monero/.bitmonero \
&& chown -R monero:monero /opt/bitmonero

COPY --from=builder /opt/monero/build/release/bin/ /opt/monero/

USER monero
WORKDIR /home/monero
Expand Down