freechipsproject / chisel-bootcamp

Generator Bootcamp Material: Learn Chisel the Right Way
Apache License 2.0
981 stars 278 forks source link

Local installation using Docker #132

Closed sterin closed 3 years ago

sterin commented 3 years ago

Hi,

On machines with Docker installed, it is much easier to run a docker image than to follow the instructions to locally install the bootcamp.

I've prepared a Dockerfile and A GitHub action that builds the docker image and pushes it to Docker Hub on each update to the GitHub repository.

If this is of interest, It would probably be better to push the image to your own account on Docker Hub. The required changes are:

  1. Create a new Docker Hub account
  2. Create an access token at https://hub.docker.com/settings/security
  3. Add new secrets at the GitHub repository names DOCKER_HUB_USERNAME and DOCKER_HUB_ACCESS_TOKEN
  4. Change the name of the repository from sterin/chisel-bootcamp to the new username/chisel-bootcamp in both install.md and .github/workflows/build-push-docker-iamge.yaml
jackkoenig commented 3 years ago

This is excellent and something I've wanted for a while, thank you @sterin!

I do have one question. Is there a way we can also make it easy to use a local clone or copy of the bootcamp content so that the user's work is saved? I get that it's saved in a Docker container if you don't pass the --rm command, but I don't think that's quite what we want. I'm thinking like using a volume or mount so that the files being modified live on the host machine rather than inside the container.

I tried it out by modifying the command to mount my local clone over the /home/bootcamp directory (docker run -it --rm -p 8888:8888 -v $PWD:/home/bootcamp sterin/chisel-bootcamp). It seemed to mount correctly, but Jupyter can't find the Scala kernel (presumably because I'm lacking local setup). Perhaps we could just change the directory structure of this repo, putting all of the .ipynb files into a subdirectory, and then mount that. We could then provide a script that runs the correct tag of the docker container to ensure it is synced with the version of the content.

Any thoughts?

sterin commented 3 years ago

I've moved the bootcamp to /chisel-bootcamp and now it's possible to mount it as a volume.

docker run -it --rm -p 8888:8888 -v $PWD:/chisel-bootcamp sterin/chisel-bootcamp

Note that you might need to get the latest version of the image using

docker pull sterin/chisel-bootcamp

It's still not ideal because the UID/GID of the bootcamp user are probably different from the user running docker. Files written by the container would be have the wrong permissions. I'll check what is the standard way of handling this.

sterin commented 3 years ago

I've made a few additional changes. The packages are installed into a global directory and so are the Jupyter config files. It seems to work with local files using a command similar to:

docker run -it --rm -p 8888:8888 -v $PWD:/chisel-bootcamp -u $(id -u ${USER}):$(id -g ${USER}) sterin/chisel-bootcamp
ducky64 commented 3 years ago

Testing this on Windows was discussed at the dev meeting today, and I was able to get this to work on Windows by:

jackkoenig commented 3 years ago

I am having issues with using the -u stuff, but I think this is in a good enough state that we should merge (with changes to have it publish to ucb-bar Dockerhub). We can work on enhancing the -v and -u workflow later.