Skip to content

Stand-alone container for a BigchainDB node#2424

Merged
ldmberman merged 5 commits intobigchaindb:masterfrom
muawiakh:docker-all-in-one
Aug 2, 2018
Merged

Stand-alone container for a BigchainDB node#2424
ldmberman merged 5 commits intobigchaindb:masterfrom
muawiakh:docker-all-in-one

Conversation

@muawiakh
Copy link
Copy Markdown
Contributor

@muawiakh muawiakh commented Jul 31, 2018

Background

  • Some customers have asked for a single stand-alone BigchainDB image.
  • Easier for early users of BigchainDB

Solution

  • Make BigchainDB, MongoDB and Tendermint be part of the same container, even though it is an anti-pattern but this has been requested at several instances by customers/partners.
  • Easier for early adopters of BigchainDB i.e. 2 step approach:
    • docker pull
    • docker run

TODOs

  • Add documentation of this workflow.
  • Tag image once this PR is merged.

Issues this Resolves

Resolves #2238 (or at least I think it does. -Troy)

@muawiakh muawiakh requested a review from ldmberman July 31, 2018 12:14
@codecov-io
Copy link
Copy Markdown

codecov-io commented Jul 31, 2018

Codecov Report

Merging #2424 into master will increase coverage by 1.2%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##           master    #2424     +/-   ##
=========================================
+ Coverage   88.43%   89.64%   +1.2%     
=========================================
  Files          39       40      +1     
  Lines        2275     2589    +314     
=========================================
+ Hits         2012     2321    +309     
- Misses        263      268      +5

@muawiakh muawiakh requested a review from shahbazn July 31, 2018 12:41
@@ -0,0 +1,84 @@
# Run BigchainDB with all-in-one Docker

**NOT for Production Use**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the production use criteria? We do not have such warnings in the docs of other setups.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For starters, a single container for multiple stateful services is not a good sign. This is a very opinionated image. For production use cases someone might need more than a single Docker image.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we all acknowledge that having all services running in a single container is an anti-pattern. This all-in-one container is just a convenience and we should have that warning here if not anywhere else.

Copy link
Copy Markdown
Contributor

@ldmberman ldmberman Aug 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anti-pattern is not really an explanation.

Moreover, any setup we have might be labeled "not for production use" at least for a reason that we do not have a stable release yet.

Therefore, to avoid disorienting the users I would refrain from such labels. Instead, we can add a recommendation to use a multi-image setup with a brief explanation of how it is better.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anti-pattern is not really an explanation.

Why?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anti-pattern is just a label.. Does such a setup perform worse? If yes, why? Is it more difficult to maintain such a setup?

I have no experience regarding this. There are some sources which suggest this is an anti-pattern but the docker documentation has no mention of it.

I am not really sure if we can say anything about the production readiness of either of these approaches until we try them ourselves?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone wants to use just a single node in production then maybe yes, because in terms of performance or maintenance it is not a big overhead. If you want to have a network it will be more complex.

Maybe if we have dynamically adding validators implemented, i.e. you deploy one node with this and dynamically add using upsert, there are some questions yet to be answered. That is why I suggested not to be used in production.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nodes are supposed to be managed by different operators. Operators may choose different ways of deploying them. What are the particular implications of one operator deciding to deploy a single image? I do not see any so far.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image does a tendermint init, which implies all the nodes spawn different chains. So operators will have to change that behavior or come up with a new workflow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense!

In other words, a single-node cluster configuration is hardcoded in the image. It is not currently well suited for deploying a network. Could you, perhaps, add such a clarification?

- MongoDB
- Tendermint

*We understand that it is an anti-pattern to run multiple services inside a docker.*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to recommend a multi-image alternative, add a link to its description, and briefly mention its benefits. it is an anti-pattern is not really an explanation so I would omit it.


# When developing with Python in a docker container, we are using PYTHONBUFFERED
# to force stdin, stdout and stderr to be totally unbuffered and to capture logs/outputs
ENV PYTHONUNBUFFERED 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this env variable used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this should be removed, since I will be removing:

pip install --no-cache-dir --process-dependency-links -e .[dev]

But this parameter is mostly required for dev use cases and since monit is maintaining the services, it does not make sense.

@kansi
Copy link
Copy Markdown
Contributor

kansi commented Aug 1, 2018

executed docker build - < Dockerfile-all-in-on, got the following error

  Running setup.py install for pycparser: started
    Running setup.py install for pycparser: finished with status 'done'
  Running setup.py install for cffi: started
    Running setup.py install for cffi: finished with status 'done'
Successfully installed cffi-1.11.5 pip-18.0 pycparser-2.18
Directory '.' is not installable. File 'setup.py' not found.
The command '/bin/sh -c apk --update add sudo bash     && apk --update add python3 openssl ca-certificates git     && apk --update add --virtual build-dependencies python3-dev         libffi-dev openssl-dev build-base jq     && apk add --no-cache libstdc++ dpkg gnupg     && pip3 install --upgrade pip cffi     && pip install --no-cache-dir --process-dependency-links -e .[dev]     && apk del build-dependencies     && rm -f /var/cache/apk/*' returned a non-zero code: 1

@@ -0,0 +1,58 @@
FROM alpine:latest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Indentation is not right here.

libffi-dev openssl-dev build-base jq \
&& apk add --no-cache libstdc++ dpkg gnupg \
&& pip3 install --upgrade pip cffi \
&& pip install --no-cache-dir --process-dependency-links -e .[dev] \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need to have dev level dependencies too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, I wrote it with another use case in mind but you are right, it is not needed anymore, atleast for this file.

ENV TMHOME=/tendermint

RUN addgroup tmuser \
&& adduser -S -G tmuser tmuser -h "$TMHOME"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to have a separate user/group for Tendermint?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is migrated from the official Tendermint docker image. Let me see if we can work without it.


pushd \$4
nohup bigchaindb start >> \$3/bigchaindb.out.log 2>> \$3/bigchaindb.err.log &
nohup bigchaindb -l DEBUG start >> \$3/bigchaindb.out.log 2>> \$3/bigchaindb.err.log &
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the log level be a variable? if bigchaindb-monit-config is intended to run and monitor production system then user should be able to select the necessary/required log level.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a step towards that, not the production template. The user can still change it using the BigchainDB configuration file. I can remove it but without Debug we have very little logs.

- Fix nitpicks
- Remove -e flag while installing because it is not needed
- Remove unwanted env variables
- Update some docs
- Clarify that this image is not well suited for a network deployment
@ldmberman
Copy link
Copy Markdown
Contributor

Created #2434, restarted the build.

@ldmberman ldmberman merged commit 66b243a into bigchaindb:master Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants