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

Add Docker image #65

Merged
merged 1 commit into from
Oct 27, 2020
Merged

Add Docker image #65

merged 1 commit into from
Oct 27, 2020

Conversation

mgcrea
Copy link
Contributor

@mgcrea mgcrea commented Jul 27, 2020

Adds a working Dockerfile to generate a ready to use Docker image.

Ideally you would have a CI job that does build the image and push automatically on success. If interested I could send another PR doing just that using GitHub actions / CircleCI.

@mgcrea mgcrea force-pushed the master branch 4 times, most recently from 7a018da to 69d243a Compare July 28, 2020 08:31
@hwwhww
Copy link
Contributor

hwwhww commented Jul 28, 2020

Hi @mgcrea! It looks good and addresses #22. 👍
Do you mind changing the target branch to dev?

@mgcrea mgcrea changed the base branch from master to dev July 28, 2020 13:35
@mgcrea
Copy link
Contributor Author

mgcrea commented Jul 28, 2020

@hwwhww thanks! Just changed the target branch, looks like there is no conflicts.

@ltfschoen
Copy link

How about a .dockerignore file

# Prevent your local modules and debug logs from being
# copied onto your Docker image and possibly overwriting
# modules installed within your image
.git
__pycache__

README.md Show resolved Hide resolved
@mgcrea
Copy link
Contributor Author

mgcrea commented Aug 1, 2020

@ltfschoen Thanks for the review+suggestions, just pushed a new commit including them. Also properly switched to the dev branch so the PR contains a single commit.

@mgcrea mgcrea force-pushed the master branch 3 times, most recently from de03fe3 to 4351a1f Compare August 1, 2020 13:01
@PandaWhisperer
Copy link

PandaWhisperer commented Aug 11, 2020

Just spent the better part of an hour trying to make a Dockerfile myself. Finally got it working, then I come here to see that someone already thought of it... 😅

Also, this version is probably better because it produces a smaller image (mine was almost 1GB because I didn't know the right packages to install, so I used buster instead of alpine).

Just tested this PR and seems to work fine for me.

@ltfschoen
Copy link

ltfschoen commented Aug 11, 2020

Another useful resource is this https://github.com/stefa2k/prysm-docker-compose.

Note that I've also created a PR in this repo showing how I went about setting it all up myself.

@PandaWhisperer
Copy link

PandaWhisperer commented Aug 11, 2020

@ltfschoen that setup is what I use to run my validators for Medalla and also the reason why I wanted to dockerize the deposit CLI.

Stefan has done a great job making the key import as simple as possible, but it still took a bit of work to get the deposit CLI working, so I thought if only there was a docker image for that, this could literally become a one stop shop for setting up a validator, no futzing around with different compilers etc. required.

Unfortunately I did not find your PR there, @ltfschoen?

@mgcrea I think one improvement that would be nice to have would be a smaller image size. Yours was 264 MB, which is already a huge improvement over my 957, but I think it could be trimmed down quite a bit using a multi-stage build, which could basically drop the compiler and devtools required for the build process and only contain what's necessary to run the actual CLI.

I tried my hand at that, but unfortunately I failed, because my image did not include the compiled eggs, so it wouldn't run.

EDIT: after a few more experiments, victory is mine! I added the following lines to the Dockerfile, just before the ENTRYPOINT directive:

FROM python:3.7-alpine

COPY --from=0 /app /app
COPY --from=0 /usr/local /usr/local

WORKDIR /app

Basically, this creates a fresh image starting over with the same base, copies the app and the installed Python modules over, and packages that as a runtime image. I ran the CLI and it seemed to be able to generate a key successfully, and the image size went down to about 120 MB.

I think this could still go down quite a bit, after all the binary distribution is only about 14 MB zipped. I also tried to make an image just for that, but I couldn't get it to work. However, the image was only 22 MB large, which would be another great improvement.

@ltfschoen
Copy link

@PandaWhisperer FYI this is the PR with what I did #83

@PandaWhisperer
Copy link

@ltfschoen oh okay, I misunderstood you then. I thought you made a PR on stefa2k/prysm-docker-compose.

@mgcrea
Copy link
Contributor Author

mgcrea commented Aug 21, 2020

Is there anything left I can do to help this being merged? Thanks!

@raunchy-mx
Copy link

raunchy-mx commented Aug 21, 2020 via email

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

Since we (EF) may not upload the docker image somewhere officially, I assume that the users have to build the docker image by themselves. That is, we probably should tell them how to build it in the document.

Otherwise, this PR looks good to me. Thank you! 😊

/cc @CarlBeek

README.md Outdated
@@ -201,6 +201,34 @@ See [here](#arguments)
###### Successful message
See [here](#successful-message)

#### Option 4. Use Docker image

##### Step 1. Create keys and `deposit_data-*.json`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the docs tell the user to build the docker image first? (make build_docker)

@hwwhww
Copy link
Contributor

hwwhww commented Oct 20, 2020

Hey @mgcrea 👋 are you still working on it?

@mgcrea
Copy link
Contributor Author

mgcrea commented Oct 22, 2020

Hey @hwwhww, yes will gladly add any changes required for this to land. I've added the make build_docker step.

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

LGTM!

/cc @CarlBeek would you like to take a look at it before merge?

@CarlBeek
Copy link
Collaborator

Looks good to me too. Thanks for your work on this @mgcrea!

@CarlBeek CarlBeek merged commit 89f0579 into ethereum:dev Oct 27, 2020
@hwwhww
Copy link
Contributor

hwwhww commented Oct 27, 2020

Thank you @mgcrea!

Ideally you would have a CI job that does build the image and push automatically on success. If interested I could send another PR doing just that using GitHub actions / CircleCI.

Would you like to help with the CI job? #123 will change the command line interface so we should have dockerfile build in CI.

everhusk pushed a commit to earthbitcoin/earth-wallet-cli that referenced this pull request Aug 3, 2023
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.

6 participants