{"id":16623688,"url":"https://github.com/jandelgado/lede-dockercompiler","last_synced_at":"2025-10-29T22:31:50.238Z","repository":{"id":47540422,"uuid":"105197377","full_name":"jandelgado/lede-dockercompiler","owner":"jandelgado","description":"Docker image to compile LEDE/OpenWrt from source","archived":false,"fork":false,"pushed_at":"2021-08-24T20:12:51.000Z","size":65,"stargazers_count":21,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-02-26T23:22:48.558Z","etag":null,"topics":["docker","imagebuilder","lede","openwrt"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jandelgado.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-28T20:43:47.000Z","updated_at":"2022-01-18T07:01:54.000Z","dependencies_parsed_at":"2022-07-25T00:02:15.365Z","dependency_job_id":null,"html_url":"https://github.com/jandelgado/lede-dockercompiler","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flede-dockercompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flede-dockercompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flede-dockercompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flede-dockercompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jandelgado","download_url":"https://codeload.github.com/jandelgado/lede-dockercompiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219857107,"owners_count":16556074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","imagebuilder","lede","openwrt"],"created_at":"2024-10-12T03:24:37.856Z","updated_at":"2025-10-29T22:31:44.931Z","avatar_url":"https://github.com/jandelgado.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dockerized LEDE/OpenWrt compile environment\n\n[![test](https://github.com/jandelgado/lede-dockercompiler/actions/workflows/test.yml/badge.svg)](https://github.com/jandelgado/lede-dockercompiler/actions/workflows/test.yml)\n\nA docker image to compile LEDE/OpenWrt images from source.\n\n\u003c!-- vim-markdown-toc GitLab --\u003e\n\n* [Quickstart](#quickstart)\n* [Build and run docker image](#build-and-run-docker-image)\n* [Using the image](#using-the-image)\n    * [Basic usage](#basic-usage)\n        * [Find build configurations](#find-build-configurations)\n    * [Compile an individual package](#compile-an-individual-package)\n    * [Adding a new package](#adding-a-new-package)\n        * [Build the OpenWrt SDK](#build-the-openwrt-sdk)\n        * [Create package structure (in-tree version)](#create-package-structure-in-tree-version)\n        * [Create package structure (custom feed version)](#create-package-structure-custom-feed-version)\n    * [Working with patches](#working-with-patches)\n        * [Change an existing patch](#change-an-existing-patch)\n* [Author and Copyright](#author-and-copyright)\n\n\u003c!-- vim-markdown-toc --\u003e\n\nNote: Look [here](https://github.com/jandelgado/lede-dockerbuilder) for a\nversion which uses the LEDE/OpenWrt imager builder, which uses pre-compiled\npackages to build the actual image (which is much faster, but has more\nlimitations regarding customizations).\n\n## Quickstart\n\nYou can directly start the image builder from the github container registry \nghcr.io:\n\n```\n$ mkdir -p workdir\n$ docker run --rm -e GOSU_UID=\"$(id -ur)\" -e GOSU_GID=\"$(id -g)\" \\\n             -v $(cd workdir; pwd):/workdir:z \\\n             -ti --rm ghcr.io/jandelgado/lede-dockercompiler:latest bash\n```\n\nThis will take you to a bash shell with an OpenWrt build environment. Local\ndirectory `workdir` will be mounted to `/workdir` in the container. See below\nfor how to use the image.\n\n## Build and run docker image\n\nUse the `builder.sh` to build and run the docker image:\n\n```\nDockerized OpenWRT compile environment.\n\nUsage: ./builder.sh COMMAND [OPTIONS] \n  COMMAND is one of:\n    build-docker-image    - build docker image\n    run CMD -- [ARGS...]  - run given command in docker container\n    shell                 - start shell in docker container\n\n  OPTIONS:\n    -o WORK_DIR           - working directory (default /home/paco/src/lede-dockercompiler/workdir)\n    --docker-opts OPTS    - additional options to pass to docker run\n                            (can occur multiple times)\n    --rootfs-overlay DIR  - rootfs overlay directory\n    --skip-sudo           - call docker directly, without sudo\n\nEnvironment:\n  IMAGE_NAME              - Tag to be used for docker image. \n                            (default: jandelgado/openwrt-imagecompiler)\n\nExample:\n  ./builder.sh shell\n  ./builder.sh shell --docker-opts \"-v=/tmp:/host-tmp\"\n  ./builder.sh run -- sh -c \"cd lede \u0026\u0026 make menuconfig defconfig world\"\n```\n\nFirst build the docker image with `./builder.sh build-docker-image`,\nthen put your source files in the `workdir/` directory and start the actual\ncontainer with the OpenWrt build environment with `./builder.sh shell`.\n\nThe last command will open a shell in the docker container with local the\n`workdir/` mounted to the directory `/workdir` in the container. Since\nworkdir is externally mounted, it's contents will survive container restarts.\n\n## Using the image\n\nSome tipps on Using the OpenWrt image, working with patches and the quilt tool\nto build your own OpenWrt package.\n\n### Basic usage\n\nStart a container as described above.  This will take you straight into a shell\nin the container, with the local `workdir` directory mounted as a volume to\n`/workdir` inside the container. On success, you'll see a prompt like\n`builder@567cbabfb36b:/workdir$`. If you need to have additional files or \ndirectories available in the container, they can be mounted using the \n`--docker-opts` option, by providing the corresponding `docker run` mount\ncommands. The [ci test workflow](.github/workflows/test.yml) provides an \n[example](example/).\n\nNow execute the following commands in the container to prepare the OpenWrt\nsource (see [this page for more\ndetails](https://lede-project.org/docs/guide-developer/quickstart-build-images)):\n\n```\ngit clone https://github.com/openwrt/openwrt lede \u0026\u0026 cd lede\ngit checkout v19.07.2\n./scripts/feeds update -a\n./scripts/feeds install -a\nmake menuconfig     # 1. set target , 2. set sub target\nmake defconfig      # to set default config for target\nmake kernel_menuconfig  # optional\nmake\n```\n\nSee also [image\ncomfiguration](https://openwrt.org/docs/guide-developer/build-system/use-buildsystem#image_configuration)\nin the OpenWrt documentation.\n\nThe resulting images can be found in `workdir/lede/bin/target` (on the host),\nor in `/workdir/lede/bin/target` in the container.\n\n#### Find build configurations\n\nThe originally used build configuration used to build the official OpenWrt\nimages [can be found e.g. here](https://downloads.openwrt.org/releases/19.07.2/targets/ar71xx/generic/config.buildinfo).\n\n### Compile an individual package\n\n```\n$ make packages/network/utils/tcpdump/{clean,compile}\n```\n\nAdd `V=s` to make , e.g. `make V=s` for enhanced verbosity.\n\n### Adding a new package\n\nThis describes how to add a new OpenWrt package. We use the\n[udptunnel](http://www.cs.columbia.edu/~lennox/udptunnel/) tool as an\nexample.\n\nSee also\n\n* https://openwrt.org/docs/guide-developer/packages\n* https://github.com/openwrt/packages/blob/master/CONTRIBUTING.md\n* https://openwrt.org/docs/guide-developer/build-system/use-buildsystem\n\n#### Build the OpenWrt SDK\n\nFirst we need to build the OpenWrt SDK:\n\n```bash\n$ make tools/install\n$ make toolchain/install\n```\n\n#### Create package structure (in-tree version)\n\nWe need to create a directory in a suitable place under the `package/`\ndirectory and create at least a [Makefile as described\nhere.](https://openwrt.org/docs/guide-developer/packages). We will place our\npackage in `package/network/util/udptunnel`.\n\n```\nudptunnel\n├── Makefile\n└── patches\n    ├── 001-multicast.patch\n    └── 002-main_code_fix.patch\n```\n\nBuild the package with\n\n```\n$ make packages/network/utils/tcpdump/{clean,compile}\n```\n\n#### Create package structure (custom feed version)\n\nThis time we place the package in a custom feed, outside the OpenWrt root.  We\nput our package to `/workdir/myfeed/net/udptunnel` (container path).\n\nThe custom feed needs to be added to `feeds.conf.default`:\n\n```\nsrc-link myfeed /workdir/myfeed\n```\n\nInstall the feed with \n\n``` bash\n$ ./scripts/feed update myfeed \u0026\u0026 ./scripts/feed install -a myfeed`\n```\n\nNow run `make menuconfig` and activate the custom feed under `[*] Image\nconfiguration` -\u003e `[*] Separate feed repositories` -\u003e `\u003c*\u003e enable feed myfeed`.\n\nThe package should now be available within the `Network` category (because we\nchose `Network` as category in the Makefile). Compile the package with \n\n```bash\n$ make package/udptunnel/{clean,compile}\n```\n\nSee [OpenWrt Hello,\nworld!](https://openwrt.org/docs/guide-developer/helloworld/start) for an\nin-depth description.\n\n### Working with patches\n\n(Adapted from https://openwrt.org/docs/guide-developer/patches)\n\nTo make the package udptunnel compile properly, we need to patch tbefore.\nOpenWrt uses the [quilt](https://en.wikipedia.org/wiki/Quilt_(software) quilt\ntool for patch management.\n\nFrom the root of your OpenWrt tree, execute:\n\n```\n$ make package/network/util/udptunnel/{clean,prepare} V=s QUILT=1\n```\n\nThen `cd` into the prepared source directory with\n```\n$ cd build_dir/target-*/udptunnel-*\n```\n\nFirst we have to apply existing patches (in case your are working on an\nexisiting OpenWrt package which already contains patches):\n\n```\n$ quilt push -a\n```\n\nThen start the first patch:\n\n```\n$ quilt new 010-main_code_fix.patch\nPatch patches/010-main_code_fix.patch is now on top\n```\n\nNow edit the sources using `quilt edit`, in our case we will edit the file\n`host2ip.c`:\n\n```\n$ quilt edit host2ip.c\nFile host2ip.c added to patch patches/010-main_code_fix.patch\n```\n\nThe `quilt` command will automatically start an editor for you, according your\n[~/.quiltc file](https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem#prepare_quilt_configuration).\n\nCheck the changes with `quilt diff` and `quilt files`. If everything is ok,\nwe can update the patch file, `010-main_code_fix.patch`:\n\n```\n$ quilt refresh\n```\n\nChange back to root of your OpenWrt tree and update the package with the\npatch:\n\n```\n$ (cd ../../.. \u0026\u0026 make package/network/utils/udptunnel/update V=s)\nmake[1]: Entering directory '/workdir/lede'\nmake[2]: Entering directory '/workdir/lede/package/network/utils/udptunnel'\nif [ -s \"/workdir/lede/build_dir/target-mipsel_24kc_musl/udptunnel-full/udptunnel-1.1/patches/series\" ]; then (cd \"/workdir/lede/build_dir/target-mipsel_24kc_musl/udptunnel-full/udptunnel-1.1\"; if quilt --quiltrc=- next \u003e/dev/null 2\u003e\u00261; then quilt --quiltrc=- push -a; else quilt --quiltrc=- top \u003e/dev/null 2\u003e\u00261; fi ); fi\ntouch \"/workdir/lede/build_dir/target-mipsel_24kc_musl/udptunnel-full/udptunnel-1.1/.quilt_checked\"\nmkdir -p ./patches\nrm -f ./patches/* 2\u003e/dev/null \u003e/dev/null\n'/workdir/lede/build_dir/target-mipsel_24kc_musl/udptunnel-full/udptunnel-1.1/patches/010-main_code_fix.patch' -\u003e './patches/010-main_code_fix.patch'\nmake[2]: Leaving directory '/workdir/lede/package/network/utils/udptunnel'\ntime: package/network/utils/udptunnel/full/update#0.07#0.04#0.12\nmake[1]: Leaving directory '/workdir/lede'\n```\n\nAs you can see, the patch `010-main_code_fix.patch` was applied.\n\nNow the patched package can be built:\n\n```\n$ (cd ../../.. \u0026\u0026 make package/network/utils/udptunnel/{clean,compile} V=s)\n```\n\nDepending on your architecture, the resulting `ipk` package can be found under\n`bin/packages/\u003carchitecture\u003e/base`, e.g.\n`./bin/packages/mipsel_24kc/base/udptunnel_1.1-1_mipsel_24kc.ipk`.\n\n#### Change an existing patch\n\nThe workflow to change an exisiting patch is similar to the above described\nworkflow:\n\n```\n# start in root of your OpenWrt source tree\n$ make package/network/utils/udptunnel/{clean,compile} V=s\n$ cd build_dir/target-*/udptunnel-*\n$ quilt series\n001-multicast.patch\n002-main_code_fix.patch\n$ quilt push 002-main_code_fix.patch\n$ quilt edit udptunnel.c\n$ quilt diff\n$ quilt refresh\n$ ( cd ../../.. \u0026\u0026 make package/network/utils/udptunnel/update V=s )  # apply patches\n$ ( cd ../../.. \u0026\u0026 make package/network/utils/udptunnel/{clean,compile} V=s )\n```\n\n## Author and Copyright\n\n(C) Copyright 2019-2020 Jan Delgado \u003cjdelgado[at]gmx.net\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandelgado%2Flede-dockercompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjandelgado%2Flede-dockercompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandelgado%2Flede-dockercompiler/lists"}