CS50 IDE's Docker configuration for Cloud9
Since Docker containers are built incrementally, building an offline container
requires first creating an underlying workspace image, then building
an ide50 image on top of that, and then finally creating the
ide50-offline image on top. There are some make
commands to
simplify this process.
The primary way to make changes to the offline workspace is to add things (required packages, scripting various installation steps, etc) to the ide50 Debian package which is also used for the online version of the IDE. The build process below builds an offline IDE based on the publicly-accessible IDE50 package on mirror.cs50.net.
First build an offline workspace from scratch using the "To build all from scratch" steps below.
Next, make changes to the ide50 Debian package, build it, and follow the directions on that repo to locally install the deb on the offline workspace (also be sure to test it on an online workspace!) you generated above.
If all goes well, publish the deb to the mirror and build the offline workspace from scratch, once there has been sufficient time for all mirrors to receive the new deb.
- Install Docker Engine.
- Open a terminal window.
- Execute
cd /path/to/ide50-docker
. - Execute
make build
and wait. This builds all images sequentially. - Start the built offline container with
make run
. - (Mac OS X only) Execute
make open
to automatically open a tab in your favorite browser that loads the offline IDE.
- Stop the running offline container with
make stop
- Delete offline image with
make clean
- Re-build offline (only) with
make offline
Rebuilding from an earlier version (say, if you need to build a new
ide50 container with a new version of the ide50 deb) will require
rebuilding from that container. It's probably easiest to delete all images
and then run make build
.
We generally deploy a new offline version when a new version of the ide50 deb is released. This way, people that download the offline version are sure to have the very latest.
- Clean all existing images and containers. Building from scratch is
generally preferred since it ensures the latest version of Ubuntu
and other packages. Use
docker ps -a
to see a full list of docker containers, stopping any relevant ones if necessary, and remove them withdocker rm
. Usedocker images
to see a list of images, and usedocker rmi
to delete those images. I usually delete all images that are associated with the offline IDE to be sure to build from scratch. - Run
make build
to build from scratch. - Run the offline with
make run
to ensure the latest deb was installed and all changes are as they appear.
If all looks good after a successful complete build, begin the actual deployment steps:
- Run
make squash
to squash the docker image into as small of a size as possible. Note: docker squash tools tend to change rapidly, so you may need to update thesquash
rule in the Makefile periodically, or update the copy of the docker-squash. - Once that's done, apply both "beta" and "latest" tags to the build version. "Beta" builds are at least as new as the "latest", but sometimes its useful to release just a "beta" build with features that others test:
docker tag ide50-offline cs50/ide50-offline:beta
docker tag ide50-offline cs50/ide50-offline:latest
- Push the tags to Docker hub:
docker push cs50/ide50-offline:beta
docker push cs50/ide50-offline:latest
There are a variety of commands in make
to help re-build an image.
make build
Builds thewkspc
image, then theide
image, then theoffline
image.- Build individual images with
make wkspc
,make ide
, andmake offline
, respectively. make run
runs an already-built offline containermake stop
then stops that running containermake open
(Mac OS X only, probably) opens the offline IDE in your browser.make shell
to open a shell in the running containermake clean
removes the offline image and container only
- Change line 1 of ide50/Dockerfile to FROM cloud9/workspace
- Zip ide50 (zip -r ide50 ide50).
- Email to Nikolai Onken, nikolai@c9.io
After making changes to CSS (e.g., in /var/c9sdk/plugins/*
) or config files (e.g., /var/c9sdk/configs/ide/workspace-cs50.js
):
cd /path/to/ide50-docker
make shell
/var/c9sdk/scripts/install-sdk.sh
exit
make restart
docker-machine regenerate-certs default
If something still seems awry with Docker, odds are the below will help. The below will delete and recreate the virtual machine used by Docker.
docker-machine stop default
docker-machine rm default
docker-machine create --driver virtualbox default
eval $(docker-machine env default)