Snipa22 / nodejs-pool

Other
479 stars 421 forks source link

Seperating Build Deps from Production Deps #335

Open TimeTravelersHackedMe opened 6 years ago

TimeTravelersHackedMe commented 6 years ago

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?

Snipa22 commented 6 years ago

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.

TimeTravelersHackedMe commented 6 years ago

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.

On Feb 25, 2018 1:20 PM, "Snipa22" notifications@github.com 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- .

shigutso commented 6 years ago

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

Snipa22 commented 6 years ago

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.

TimeTravelersHackedMe commented 6 years ago

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 commented 6 years ago

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

Snipa22 commented 6 years ago

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.