{"id":13876057,"url":"https://github.com/s8sg/firecracker-go-template","last_synced_at":"2025-07-14T08:32:44.863Z","repository":{"id":83014074,"uuid":"165784768","full_name":"s8sg/firecracker-go-template","owner":"s8sg","description":"Builds firecracker filesystem with provided Go application","archived":false,"fork":false,"pushed_at":"2019-01-16T06:29:18.000Z","size":14,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-05T02:45:03.399Z","etag":null,"topics":["firecracker","firecracker-go","firecracker-microvms","golang","unikernel"],"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/s8sg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-01-15T04:23:20.000Z","updated_at":"2025-03-14T00:58:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb43280a-7dcd-427c-b7fc-bbc44dbf322f","html_url":"https://github.com/s8sg/firecracker-go-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/s8sg/firecracker-go-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Ffirecracker-go-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Ffirecracker-go-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Ffirecracker-go-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Ffirecracker-go-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s8sg","download_url":"https://codeload.github.com/s8sg/firecracker-go-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s8sg%2Ffirecracker-go-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265262644,"owners_count":23736439,"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":["firecracker","firecracker-go","firecracker-microvms","golang","unikernel"],"created_at":"2024-08-06T06:00:59.149Z","updated_at":"2025-07-14T08:32:44.843Z","avatar_url":"https://github.com/s8sg.png","language":"Shell","funding_links":[],"categories":["Shell","golang"],"sub_categories":[],"readme":"# firecracker-go-template\nBuilds firecracker filesystem with provided Go application   \n   \n\u003e This repository is a direct copy and edit on **UNIK's firecracker compiler**  \n\u003e For more details on UNIK click [here](https://github.com/solo-io/unik)  \n  \n  \n## Getting Started\n   \n**Prerequisites**\n```text\ndocker\nfirecracker\nfirectl\n```\n**Get firecracker kernel**\n```bash\ncurl -fsSL -o /tmp/hello-vmlinux.bin https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin\n```\n\n\n**Setup tap interface - Optional for network**\n```bash\nsudo ip tuntap add tap0 mode tap # user $(id -u) group $(id -g)\nsudo ip addr add 172.20.0.1/24 dev tap0\nsudo ip link set tap0 up\n```\nSet your main interface device. If you have different name check it with ifconfig command\n```bash\nDEVICE_NAME=eth0\n```\nProvide iptables rules to enable packet forwarding\n```bash\nsudo sh -c \"echo 1 \u003e /proc/sys/net/ipv4/ip_forward\"\nsudo iptables -t nat -A POSTROUTING -o $DEVICE_NAME -j MASQUERADE\nsudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT\nsudo iptables -A FORWARD -i tap0 -o $DEVICE_NAME -j ACCEPT\n```\n   \n### Build docker image\n```bash\nmake\n```\n\n## Write your simple golang application  \n   \n##### 1. Write your demo go application\n```bash\nmkdir demo\ncat \u003e demo/main.go \u003c\u003cEOF\npackage main\n\nimport (\n  \"fmt\"\n  \"os/exec\"\n  \"time\"\n)\n\nfunc main() {\n  for {\n    fmt.Println(\"Hello from firecracker (run by unik from solo.io)\")\n    out, _ := exec.Command(\"uname\", \"-a\").CombinedOutput()\n    fmt.Printf(\"OS Version: %s\\n\", string(out))\n    time.Sleep(10 * time.Second)\n  }\n}\nEOF\n```\n    \n##### 2. Build root filesystem using `build` script\n```bash\n./build ./demo my_root_fs\n```\n   \n##### 3. Use `firectl` to run firecracker with your rootfs\n```bash\nROOTFS=\"$(readlink -f my_root_fs)\"\nsudo firectl \\\n   --kernel=/tmp/hello-vmlinux.bin \\\n   --root-drive=$ROOTFS \\ \n   --kernel-opts=\"console=ttyS0 noapic reboot=k panic=1 pci=off nomodules rw\" \n```\n    \n## Write your golang Http Server (need tap device setup)\n   \n##### 1. Write your demo go application\n```bash\nmkdir demo\ncat \u003e demo/main.go \u003c\u003cEOF\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n    fmt.Fprintf(w, \"Hi there, I love %s!\", r.URL.Path[1:])\n}\n\nfunc main() {\n    http.HandleFunc(\"/\", handler)\n    log.Fatal(http.ListenAndServe(\":8080\", nil))\n}\nEOF\n```\n    \n##### 2. Build root filesystem using `build` script\n```bash\n./build ./demo my_root_fs 172.20.0.2/24 172.20.0.1\n```\n   \n##### 3. Use `firectl` to run firecracker with your rootfs\n```bash\nMAC=\"$(cat /sys/class/net/tap0/address)\"\nROOTFS=\"$(readlink -f my_root_fs)\"\nsudo firectl \\\n   --kernel=/tmp/hello-vmlinux.bin \\\n   --root-drive=$ROOTFS \\ \n   --kernel-opts=\"console=ttyS0 noapic reboot=k panic=1 pci=off nomodules rw\" \\ \n   --tap-device=tap0/$MAC\n```\n\n##### 4. Test your application server\n```bash\ncurl http://172.20.0.2:8080/firecracker\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs8sg%2Ffirecracker-go-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs8sg%2Ffirecracker-go-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs8sg%2Ffirecracker-go-template/lists"}