Skip to content

Instantly share code, notes, and snippets.

@dougvk
Last active January 27, 2020 20:28
Show Gist options
  • Save dougvk/54ec3304ef95ae5d45d2eb897f6c87e0 to your computer and use it in GitHub Desktop.
Save dougvk/54ec3304ef95ae5d45d2eb897f6c87e0 to your computer and use it in GitHub Desktop.
Building Urbit with Docker

Create your docker-machine

This works with everything docker-machine can work on (DigitalOcean, Amazon AWS, virtualbox, local, &c.). N.B. urbit needs at least 2GB of memory or it fails.

My favorite guide is here, but this one is good...and so is this. AWS is a little tricky (due to security groups, &c.), and worth checking out a specific guide.. Also, if you're using Docker Beta on your Mac, this should be helpful if you just want to use docker-machine locally.

e.g.:

docker-machine create -d digitalocean \
--digitalocean-access-token <ACCESS_TOKEN>
--digitalocean-size 4gb \
--digitalocean-image ubuntu-16-04-x64 \
dobox

Choose your machine, and build the urbit

In this example, I'm going to use my Digital Ocean box named dobox.

First, we have to set the right environment vars in our shell:

~ % eval $(docker-machine env dobox)
~ % export DOCKER_API_VERSION=1.23
~ % docker-machine ls
NAME    ACTIVE   DRIVER         STATE     URL                         SWARM   DOCKER    ERRORS
dobox   *        digitalocean   Running   tcp://159.203.78.109:2376           v1.11.2

Next, we build then run:

docker-compose build
docker-compose up -d

Once run, we should be able to see it up:

~ % docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
8bd1216a0317        urbit_planet        "bash -c 'cp -rn /urb"   13 hours ago        Up 13 hours                             urbit_planet_1

Finally, we can build our urbit (from the /planet/urbit directory) with the command bin/urbit -w <planet name> -t <ticket> OR just make a comet using bin/urbit -c <comet name>. For more info, see the setup docs. Here, my planet name was fotsev-habnut and I built the planet like this:

~ % docker exec -it 8bd1216 /bin/bash
root@8bd1216a0317:/urbit# cd /planet
root@8bd1216a0317:/planet# cd urbit/
root@8bd1216a0317:/planet/urbit# bin/urbit -w fotsev-habnut -t <HIDDEN>

Once built, I can attach to the docker instance and boot up my urbit whenever I want!

~ % docker exec -it 8bd1216 /bin/bash
root@8bd1216a0317:/urbit# cd /planet
root@8bd1216a0317:/planet# cd urbit/
root@8bd1216a0317:/planet/urbit# bin/urbit fotsev-habnut
~
urbit: home is fotsev-habnut
loom: mapped 2048MB
protected loom
live: loaded: MB/92.815.360
boot: installed 214 jets
arvo: time: ~2016.7.13..13.00.33..0b64
rest: checkpoint to event 6.850
rest: old 0v1b.0t4qt, new 0v3.8q3om
loaded passcode from fotsev-habnut/.urb/code.~disrys-hilsut

---------------- playback complete----------------
ames: on localhost, UDP 54652.
http: live (insecure, public) on 8080
http: live ("secure", public) on 8443
http: live (insecure, loopback) on 12321
ames: czar zod.urbit.org: ip .104.197.80.248
~fotsev-habnut:talk()
planet:
build: .
command: bash -c "cp -rn /urbit /planet && tail -f /dev/null"
volumes_from:
- planet_data
environment:
TERM: xterm-256color
ports:
- "8080:8080"
planet_data:
image: busybox
volumes:
- /planet
FROM ubuntu:latest
RUN apt-get update -y && apt-get install -y \
libgmp3-dev libsigsegv-dev openssl libssl-dev \
libncurses5-dev git make exuberant-ctags automake autoconf libtool \
g++ ragel cmake re2c curl
RUN git clone https://github.com/urbit/urbit /urbit
WORKDIR /urbit
RUN make
RUN curl -o urbit.pill https://bootstrap.urbit.org/latest.pill
@yebyen
Copy link

yebyen commented Jul 25, 2016

And even older, https://github.com/yebyen/urbinit

These both (yours, not mine) look like solutions from people who know how Docker is supposed to work. Great looking!

Also, NB. you can run Urbit with fewer than two GB of memory. The change is in i/n/a.h (I think that's include/noun/allocate.h now) where 29 loom bits is changed to 28. That tells Urbit to let loom allocate only half as much memory, in powers of two.

I used this to work on 32-bit platforms where allocating 2GB of contiguous RAM is pretty unlikely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment