nodejs-pool icon indicating copy to clipboard operation
nodejs-pool copied to clipboard

Seperating Build Deps from Production Deps

Open TimeTravelersHackedMe opened this issue 7 years ago • 7 comments

Hey, I'm trying to make a slimmed down Docker image that only includes software necessary to run NodeJS-Pool. My question is which of these packages are necessary to run NodeJS-Pool?

git curl python-virtualenv nodejs npm python3-virtualenv build-essential cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev lmdb-utils libzmq3-dev

My hypothesis:

Build requirements: git curl build-essential cmake pkg-config libboost-all-dev libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev libzmq3-dev

Production requirements: python-virtualenv npm nodejs python3-virtualenv lmdb-utils

Anyone know if I'm missing any production requirements or if I can move the python packages to build requirements?

TimeTravelersHackedMe avatar Feb 24 '18 02:02 TimeTravelersHackedMe

The majority of these are required for the Monero daemon compilation, which, needs to be done, therefore, needs to be included for the most part. In general, I wouldn't touch the requirements.

Snipa22 avatar Feb 25 '18 18:02 Snipa22

I'm trying to create a build image which generates artifacts and then is passed to a production instance. This way everything is compact and only necessary files are present on the system.

  • Brian

On Feb 25, 2018 1:20 PM, "Snipa22" [email protected] wrote:

The majority of these are required for the Monero daemon compilation, which, needs to be done, therefore, needs to be included for the most part. In general, I wouldn't touch the requirements.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Snipa22/nodejs-pool/issues/335#issuecomment-368331537, or mute the thread https://github.com/notifications/unsubscribe-auth/AFaOlswXTz8yR_kqwMrqOUAXVFL_Y85Aks5tYaR6gaJpZM4SRtv- .

TimeTravelersHackedMe avatar Feb 26 '18 16:02 TimeTravelersHackedMe

install ubuntu-minimal in a vm and see if the deploy script works

shigutso avatar Feb 26 '18 17:02 shigutso

Understandable that you're attempting to slim this down. However, this code doesn't play nicely in docker containers in general. One major issue is that the CN algo needs raw malloc to play particularly nicely, secondly, abstraction around LMDB tends to break things.

Snipa22 avatar Mar 01 '18 03:03 Snipa22

I'm not sure what you mean by "One major issue is that the CN algo needs raw malloc to play particularly nicely, secondly, abstraction around LMDB tends to break things."

Here's what I have that seems to be working. I think we should move to a Docker based system since the code doesn't support multiple coins within the same database. With Docker, users can spin up instances for each coin they want to support:

FROM ubuntu:latest as builder

RUN apt-get update \
    && apt-get upgrade -y \
    && apt-get install -y --no-install-recommends \
        build-essential \
        ca-certificates \
        curl \
        git \
        gnupg \
        libboost-all-dev \
        libzmq3-dev \
        make \
        software-properties-common \
    && curl -sL https://deb.nodesource.com/setup_9.x | bash \
    && apt-get -qq install -y nodejs \
    && npm install -g n \
    && n 8.9.3 \
    && cd /root \
    && git clone https://github.com/TimeTravelersHackedMe/nodejs-pool.git \
    && cd nodejs-pool \
    && npm install \
    && openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.pool" -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem -days 36500

FROM ubuntu:latest

WORKDIR /opt/pool

COPY --from=builder /root/nodejs-pool/ /opt/pool/

RUN apt-get update \
    && apt-get upgrade -y \
    && apt-get install -y --no-install-recommends \
        curl \
        gnupg \
        libboost-all-dev \
        software-properties-common \
    && curl -sL https://deb.nodesource.com/setup_9.x | bash \
    && apt-get -qq install -y nodejs \
    && npm install -g n pm2 \
    && n 8.9.3 \
    && pm2 install pm2-logrotate
    
EXPOSE 8000 8001 3333 5555 7777 9000

CMD ["pm2-docker", "process.json"]

TimeTravelersHackedMe avatar Mar 01 '18 03:03 TimeTravelersHackedMe

This code will just make the API/Leaf/Pools available. I'm using nginx to proxy_pass and serve the web content.

TimeTravelersHackedMe avatar Mar 01 '18 04:03 TimeTravelersHackedMe

As previously stated, I am 100% against dockerizing the project fully, I would strongly suggest you look into LMDB, and how the database structures work, as LMDB is rather touchy as it is. It's trivial to install parallel copies of the pool, using a global MySQL instance, with separate databases and separate data directories, I personally have 8 pools running on a single server for various testing/development purposes, all with distinct data directories and management via a single SQL instance.

Also, look into the CN algo, and what it requires, and you'll quickly see why it's not worth considering trying to run multiple busy servers on a single node. Hash verification is extremely painful.

Snipa22 avatar Mar 01 '18 04:03 Snipa22