|
| 1 | +# Test-driving the Bistro UI |
| 2 | + |
| 3 | + |
| 4 | +## Security: words to the wise |
| 5 | + |
| 6 | +**IMPORTANT:** The "test-drive" Docker-based scripts provided for the UI and |
| 7 | +for the back-end are emphatically **NOT** appropriate for production use. |
| 8 | + |
| 9 | +I am paranoid, but If I were you, I would run them in a VM with highly |
| 10 | +restricted access to the Internet: |
| 11 | + |
| 12 | + - No inbound connections, |
| 13 | + - Allow outgoing connections only to Github, to the Docker repo hosing the |
| 14 | + Ubuntu image, and to the Ubuntu package-management servers. |
| 15 | + |
| 16 | +Upon completing the setup below, you would fire up a browser inside the VM |
| 17 | +to play with the UI. |
| 18 | + |
| 19 | +Some specific security issues with these demos include: |
| 20 | + |
| 21 | + - Everything runs as `root` -- don't kid yourself, Linux kernel isolation |
| 22 | + used by Docker is not perfect, so this is `root` on the host VM too. |
| 23 | + - Docker's security model -- more in `build/fbcode_builder/README.docker`. |
| 24 | + - Lack of code hash / signature verification on the Github code. |
| 25 | + - Lack of production hardening on the Phabricator set-up. |
| 26 | + - Lack of production hardening on the Bistro back-end setup. |
| 27 | + - Default MySQL password in containers. |
| 28 | + - `bistro.get-state-hostname-suffix` is set to '', instead of a safe value. |
| 29 | + |
| 30 | +The above list is definitely not complete. |
| 31 | + |
| 32 | + |
| 33 | +## Start the backend first |
| 34 | + |
| 35 | +First, you'll want a running back-end. The quickest way to get one is: |
| 36 | + - Use `build/fbcode_builder/README.md` to quickly build the binaries, |
| 37 | + - Follow `bistro/scripts/docker_toy/README.md` to start a toy deployment. |
| 38 | + |
| 39 | +Once that's ready, let's bring up a second Docker image with a web server |
| 40 | +hosting the Bistro UI on port 80. |
| 41 | + |
| 42 | + |
| 43 | +## Docker build |
| 44 | + |
| 45 | +Run this |
| 46 | + |
| 47 | + ./docker_build.sh &> docker_build.log ; tail docker_build.log |
| 48 | + |
| 49 | + |
| 50 | +## Start the Bistro UI in a Docker container |
| 51 | + |
| 52 | +Start an interactive session in the UI image you just built: |
| 53 | + |
| 54 | + docker run --rm -it --expose 80 $(docker images -q | head -n1) /bin/bash |
| 55 | + service mysql start |
| 56 | + service apache2 start |
| 57 | + |
| 58 | + |
| 59 | +## Connect to the Bistro UI from outside the container |
| 60 | + |
| 61 | +To connect, your browser will need to send a request to the container's IP |
| 62 | +address with `phabdocker.example.com` in the `Host` header. The easiest way |
| 63 | +is to add an appropriate line to `/etc/hosts` via the command below. If you |
| 64 | +already have a browser extension that lets you set the `Host` header for |
| 65 | +IPs, use that instead. |
| 66 | + |
| 67 | + sudo apt-get install jq # If not already installed. |
| 68 | + ( |
| 69 | + echo "# Phabricator docker image virtual host" |
| 70 | + echo "$(docker inspect $(docker ps -q | head -n1) | |
| 71 | + jq -r .[0].NetworkSettings.IPAddress) phabdocker.example.com" |
| 72 | + ) | sudo tee -a /etc/hosts |
| 73 | + |
| 74 | +*Reminder:* clean up your `/etc/hosts` once you're done test-driving Bistro. |
| 75 | + |
| 76 | +Now, you can go to `http://phabdocker.example.com` in your browser. Phabricator |
| 77 | +will ask you to register an admin account. Enter some fake data to continue. |
| 78 | + |
| 79 | +After account setup: |
| 80 | + - Go to `http://phabdocker.example.com/bistro` |
| 81 | + - Click the "Hostport List" radio button next to "Host:port Source" |
| 82 | + - Enter `BACKEND_CONTAINER_IP:31415` into "Host:port Data". |
| 83 | + - Click "View Jobs". |
| 84 | + - The next page will have colored bars representing groups of tasks. |
| 85 | + Click on one of the colored areas, then click on a task links in the |
| 86 | + revealed panel to see the task's logs. |
| 87 | + |
| 88 | + |
| 89 | +## Toy example caveats |
| 90 | + |
| 91 | +- Read `Security: word to the wise` at the top of this file! |
| 92 | + |
| 93 | +- Your Docker-based UI will be in UTC. Change the container's timezone if |
| 94 | + that's annoying. |
| 95 | + |
| 96 | +- The in-container Phabricator install has a lot of set-up issues. This is a |
| 97 | + minimal example, for production use you would want to address them. |
| 98 | + |
| 99 | + |
| 100 | +## Docker disk usage tip: finding images unused by the latest build |
| 101 | + |
| 102 | +If you are building a lot of Docker containers, they tend to eat up disk |
| 103 | +quickly. This command will list image IDs that are **NOT** in use by your |
| 104 | +latest build: |
| 105 | + |
| 106 | + sort <(docker images -qa) <( |
| 107 | + grep '^ ---> [0-9a-f]\+$' docker_build.log | cut -f 3- -d\ | sed p |
| 108 | + ) | uniq -u |
| 109 | + |
| 110 | +Upon checking the output, you can wrap the command with `docker rmi $(...)` |
| 111 | +to delete the images. |
0 commit comments