|
| 1 | +--- |
| 2 | +id: docker |
| 3 | +title: Using the Docker image |
| 4 | +sidebar_label: Using the Docker image |
| 5 | +--- |
| 6 | + |
| 7 | +import {OssOnly, FbInternalOnly} from 'internaldocs-fb-helpers'; |
| 8 | +import {SrcFile,SrcFileLink} from '@site/utils'; |
| 9 | + |
| 10 | + |
| 11 | +:::warning |
| 12 | + |
| 13 | +The Docker image is currently not working; however building Glean from |
| 14 | +scratch is now significantly easier than it was in the past, so we |
| 15 | +recommend just heading over to [Building Glean from |
| 16 | +Source](building.md). |
| 17 | + |
| 18 | +::: |
| 19 | + |
| 20 | +We provide a Docker image containing a pre-built set of Glean binaries |
| 21 | +that you can try out. These images are built automatically by a |
| 22 | +[Github Action](https://github.com/facebookincubator/Glean/blob/master/.github/workflows/glean-docker.yml). |
| 23 | + |
| 24 | +Pull the latest demo Docker image (warning, this is around 7GB): |
| 25 | + |
| 26 | +``` |
| 27 | +docker pull ghcr.io/facebookincubator/glean/demo:latest |
| 28 | +``` |
| 29 | + |
| 30 | +Run it: |
| 31 | + |
| 32 | +``` |
| 33 | +docker run -it -p 8888:8888 ghcr.io/facebookincubator/glean/demo:latest |
| 34 | +``` |
| 35 | + |
| 36 | +:::info |
| 37 | + |
| 38 | +What's in the image? |
| 39 | + |
| 40 | +* A build of Glean, in `/glean-code` |
| 41 | +* The [flow](https://github.com/facebook/flow/) binary, in `/usr/local/bin/flow` |
| 42 | +* A checkout of [react](https://github.com/facebook/react/) in `/react-code` |
| 43 | +* A Glean database containing the Flow index of React in `/gleandb` |
| 44 | + |
| 45 | +::: |
| 46 | + |
| 47 | +Start the Glean [shell](shell.md): |
| 48 | + |
| 49 | +``` |
| 50 | +glean shell --db-root /glean-demo/db --schema /glean-demo/schema/source |
| 51 | +``` |
| 52 | + |
| 53 | +You should see: |
| 54 | + |
| 55 | +``` |
| 56 | +Glean Shell, built on <time>, from rev <unknown> |
| 57 | +type :help for help. |
| 58 | +> |
| 59 | +``` |
| 60 | + |
| 61 | +The demo image contains a pre-generated database containing the |
| 62 | +results of running the Flow indexer on the React repository: |
| 63 | + |
| 64 | +``` |
| 65 | +> :list |
| 66 | +react/0 (complete) |
| 67 | + Created: 2021-05-24T02:42:33Z (30 days, 9 hours ago) |
| 68 | +``` |
| 69 | + |
| 70 | +We can look at the contents: |
| 71 | + |
| 72 | +``` |
| 73 | +react> :db react |
| 74 | +using database react/0 |
| 75 | +react> :stat |
| 76 | +flow.Declaration.3 |
| 77 | + count: 26756 |
| 78 | + size: 888756 (867.93 kB) 4.8248% |
| 79 | +... |
| 80 | +Total size: 17.57 MB |
| 81 | +``` |
| 82 | + |
| 83 | +## Running the server |
| 84 | + |
| 85 | +Above we showed the shell reading the database from the filesystem |
| 86 | +directly. Instead we can run a server that the clients will interact |
| 87 | +with to make queries: |
| 88 | + |
| 89 | +``` |
| 90 | +glean-server --db-root /glean-demo/db --schema /glean-demo/schema/source --port 12345 |
| 91 | +``` |
| 92 | + |
| 93 | +And now the shell can connect to the server: |
| 94 | + |
| 95 | +``` |
| 96 | +glean shell --service localhost:12345 |
| 97 | +``` |
| 98 | + |
| 99 | +The commands work exactly the same as with local databases, but now it |
| 100 | +would also work over the network. |
| 101 | + |
| 102 | +## Hyperlink demo |
| 103 | + |
| 104 | +We have a small demo showing how Glean can enable code navigation. The <SrcFileLink file="glean/demo/Hyperlink.hs">glean-hyperlink</SrcFileLink> tool |
| 105 | +creates a webserver that serves hyperlinked source code using data |
| 106 | +from a specified Glean database. |
| 107 | + |
| 108 | +We can navigate the React source code as follows. First start the |
| 109 | +Glean server: |
| 110 | + |
| 111 | +``` |
| 112 | +glean-server --db-root /glean-demo/db --schema /glean-demo/schema/source --port 12345 |
| 113 | +``` |
| 114 | + |
| 115 | +Next start the Hyperlink server: |
| 116 | + |
| 117 | +``` |
| 118 | +glean-hyperlink --service localhost:12345 --db react --root /react-code --http 8888 |
| 119 | +``` |
| 120 | + |
| 121 | +Now navigate to `http://localhost:8888` in your browser, and you |
| 122 | +should see a list of source files. Click on a file, and navigate |
| 123 | +around the code by clicking on a symbol reference to jump to its |
| 124 | +definition. Try something substantial like |
| 125 | +`react-dom/src/client/ReactDOMComponent.js` |
| 126 | +(http://localhost:8888/packages/react-dom/src/client/ReactDOMComponent.js) - |
| 127 | +note how Glean is accurately linking both local and imported |
| 128 | +symbols. |
0 commit comments