Fossil SCM
build.wiki: added a section on building a static binary using Docker, adapted from https://fossil-scm.org/forum/forumpost/5dd2d61e5f.
Commit
942be4c8947f45663bf88708ab071a50bdc0837d84197c7784b8813508b89808
Parent
a9027e7d10e2fd2…
1 file changed
+81
+81
| --- www/build.wiki | ||
| +++ www/build.wiki | ||
| @@ -229,5 +229,86 @@ | ||
| 229 | 229 | TCC += -DWITHOUT_ICONV |
| 230 | 230 | TCC += -Dsocketlen_t=int |
| 231 | 231 | TCC += -DSQLITE_MAX_MMAP_SIZE=0 |
| 232 | 232 | </pre></blockquote> |
| 233 | 233 | </ul> |
| 234 | + | |
| 235 | +<h2>5.0 Building a Static Binary on Linux using Docker</h2> | |
| 236 | + | |
| 237 | +Building a static binary on Linux is not as straightforward as it | |
| 238 | +could be because the GNU C library requires that certain components be | |
| 239 | +dynamically loadable. That can be worked around by building against a | |
| 240 | +different C library, which is simplest to do by way of a container | |
| 241 | +environment like [https://www.docker.com/ | Docker]. | |
| 242 | + | |
| 243 | +The following instructions for building fossil using Docker | |
| 244 | +were adapted from [https://fossil-scm.org/forum/forumpost/5dd2d61e5f | forumpost/5dd2d61e5f]. | |
| 245 | +These instructions assume that docker is installed and that the user running | |
| 246 | +these instructions has permission to do so (i.e., they are <tt>root</tt> or | |
| 247 | +are a member of the <tt>docker</tt> group). | |
| 248 | + | |
| 249 | +First, create a file named <tt>Dockerfile</tt> with the following contents: | |
| 250 | + | |
| 251 | +<pre><code> | |
| 252 | +FROM alpine:edge | |
| 253 | +RUN apk update \ | |
| 254 | + && apk upgrade \ | |
| 255 | + \ | |
| 256 | + && apk add --no-cache \ | |
| 257 | + curl gcc make tcl \ | |
| 258 | + musl-dev \ | |
| 259 | + openssl-dev zlib-dev \ | |
| 260 | + openssl-libs-static zlib-static \ | |
| 261 | + \ | |
| 262 | + && curl \ | |
| 263 | + "https://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=trunk" \ | |
| 264 | + -o fossil-src.tar.gz \ | |
| 265 | + \ | |
| 266 | + && tar xf fossil-src.tar.gz \ | |
| 267 | + && cd fossil-src \ | |
| 268 | + \ | |
| 269 | + && ./configure \ | |
| 270 | + --static \ | |
| 271 | + --disable-fusefs \ | |
| 272 | + --with-th1-docs \ | |
| 273 | + --with-th1-hooks \ | |
| 274 | + \ | |
| 275 | + && make | |
| 276 | +</code></pre> | |
| 277 | + | |
| 278 | +Be sure to modify the <tt>configure</tt> flags, if desired. e.g., add <tt>--json</tt> | |
| 279 | +for JSON support. | |
| 280 | + | |
| 281 | +From the directory containing that file, build it with docker: | |
| 282 | + | |
| 283 | +<pre><code># docker build -t fossil_static .</code></pre> | |
| 284 | + | |
| 285 | +If you get permissions errors when running that as a non-root user, | |
| 286 | +be sure to add the user to the <tt>docker</tt> group before trying | |
| 287 | +again. | |
| 288 | + | |
| 289 | +That creates a docker image and builds a static fossil binary inside | |
| 290 | +it. That step will take several minutes or more, depending on the | |
| 291 | +speed of the build environment. | |
| 292 | + | |
| 293 | +Next, create a docker container to host the image we just created: | |
| 294 | + | |
| 295 | +<pre><code># docker create --name fossil fossil_static</code></pre> | |
| 296 | + | |
| 297 | +Then copy the fossil binary from that container: | |
| 298 | + | |
| 299 | +<pre><code># docker cp fossil:/fossil-src/fossil fossil</code></pre> | |
| 300 | + | |
| 301 | +The resulting binary will be <em>huge</em> because it is built with | |
| 302 | +debug info. To strip that information, reducing the size greatly: | |
| 303 | + | |
| 304 | +<pre><code># strip fossil</code></pre> | |
| 305 | + | |
| 306 | +To delete the Docker container and image (if desired), run: | |
| 307 | + | |
| 308 | +<pre><code># docker container rm fossil | |
| 309 | +# docker image ls | |
| 310 | +</code></pre> | |
| 311 | + | |
| 312 | +Note the IDs of the images named <tt>fossil_static</tt> and <tt>alpine</tt>, then: | |
| 313 | + | |
| 314 | +<pre><code>docker image rm THE_FOSSIL_ID THE_ALPINE_ID</code></pre> | |
| 234 | 315 |
| --- www/build.wiki | |
| +++ www/build.wiki | |
| @@ -229,5 +229,86 @@ | |
| 229 | TCC += -DWITHOUT_ICONV |
| 230 | TCC += -Dsocketlen_t=int |
| 231 | TCC += -DSQLITE_MAX_MMAP_SIZE=0 |
| 232 | </pre></blockquote> |
| 233 | </ul> |
| 234 |
| --- www/build.wiki | |
| +++ www/build.wiki | |
| @@ -229,5 +229,86 @@ | |
| 229 | TCC += -DWITHOUT_ICONV |
| 230 | TCC += -Dsocketlen_t=int |
| 231 | TCC += -DSQLITE_MAX_MMAP_SIZE=0 |
| 232 | </pre></blockquote> |
| 233 | </ul> |
| 234 | |
| 235 | <h2>5.0 Building a Static Binary on Linux using Docker</h2> |
| 236 | |
| 237 | Building a static binary on Linux is not as straightforward as it |
| 238 | could be because the GNU C library requires that certain components be |
| 239 | dynamically loadable. That can be worked around by building against a |
| 240 | different C library, which is simplest to do by way of a container |
| 241 | environment like [https://www.docker.com/ | Docker]. |
| 242 | |
| 243 | The following instructions for building fossil using Docker |
| 244 | were adapted from [https://fossil-scm.org/forum/forumpost/5dd2d61e5f | forumpost/5dd2d61e5f]. |
| 245 | These instructions assume that docker is installed and that the user running |
| 246 | these instructions has permission to do so (i.e., they are <tt>root</tt> or |
| 247 | are a member of the <tt>docker</tt> group). |
| 248 | |
| 249 | First, create a file named <tt>Dockerfile</tt> with the following contents: |
| 250 | |
| 251 | <pre><code> |
| 252 | FROM alpine:edge |
| 253 | RUN apk update \ |
| 254 | && apk upgrade \ |
| 255 | \ |
| 256 | && apk add --no-cache \ |
| 257 | curl gcc make tcl \ |
| 258 | musl-dev \ |
| 259 | openssl-dev zlib-dev \ |
| 260 | openssl-libs-static zlib-static \ |
| 261 | \ |
| 262 | && curl \ |
| 263 | "https://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=trunk" \ |
| 264 | -o fossil-src.tar.gz \ |
| 265 | \ |
| 266 | && tar xf fossil-src.tar.gz \ |
| 267 | && cd fossil-src \ |
| 268 | \ |
| 269 | && ./configure \ |
| 270 | --static \ |
| 271 | --disable-fusefs \ |
| 272 | --with-th1-docs \ |
| 273 | --with-th1-hooks \ |
| 274 | \ |
| 275 | && make |
| 276 | </code></pre> |
| 277 | |
| 278 | Be sure to modify the <tt>configure</tt> flags, if desired. e.g., add <tt>--json</tt> |
| 279 | for JSON support. |
| 280 | |
| 281 | From the directory containing that file, build it with docker: |
| 282 | |
| 283 | <pre><code># docker build -t fossil_static .</code></pre> |
| 284 | |
| 285 | If you get permissions errors when running that as a non-root user, |
| 286 | be sure to add the user to the <tt>docker</tt> group before trying |
| 287 | again. |
| 288 | |
| 289 | That creates a docker image and builds a static fossil binary inside |
| 290 | it. That step will take several minutes or more, depending on the |
| 291 | speed of the build environment. |
| 292 | |
| 293 | Next, create a docker container to host the image we just created: |
| 294 | |
| 295 | <pre><code># docker create --name fossil fossil_static</code></pre> |
| 296 | |
| 297 | Then copy the fossil binary from that container: |
| 298 | |
| 299 | <pre><code># docker cp fossil:/fossil-src/fossil fossil</code></pre> |
| 300 | |
| 301 | The resulting binary will be <em>huge</em> because it is built with |
| 302 | debug info. To strip that information, reducing the size greatly: |
| 303 | |
| 304 | <pre><code># strip fossil</code></pre> |
| 305 | |
| 306 | To delete the Docker container and image (if desired), run: |
| 307 | |
| 308 | <pre><code># docker container rm fossil |
| 309 | # docker image ls |
| 310 | </code></pre> |
| 311 | |
| 312 | Note the IDs of the images named <tt>fossil_static</tt> and <tt>alpine</tt>, then: |
| 313 | |
| 314 | <pre><code>docker image rm THE_FOSSIL_ID THE_ALPINE_ID</code></pre> |
| 315 |