{"id":13614345,"url":"https://github.com/mholt/caddy-embed","last_synced_at":"2025-04-07T05:34:15.149Z","repository":{"id":52946698,"uuid":"521069428","full_name":"mholt/caddy-embed","owner":"mholt","description":"Caddy plugin for embedding static files directly into the server binary","archived":false,"fork":false,"pushed_at":"2023-11-21T21:50:04.000Z","size":37,"stargazers_count":60,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-22T14:05:13.410Z","etag":null,"topics":["caddy","caddy-plugin","embed"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mholt.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}},"created_at":"2022-08-04T00:13:34.000Z","updated_at":"2025-02-23T17:27:40.000Z","dependencies_parsed_at":"2024-01-17T00:19:02.990Z","dependency_job_id":"83464174-1ab3-4256-a1e0-33e205e7447b","html_url":"https://github.com/mholt/caddy-embed","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"6bbec9d65515ffdb40060d84255826f4fef6126c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mholt%2Fcaddy-embed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mholt%2Fcaddy-embed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mholt%2Fcaddy-embed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mholt%2Fcaddy-embed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mholt","download_url":"https://codeload.github.com/mholt/caddy-embed/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601378,"owners_count":20964861,"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":["caddy","caddy-plugin","embed"],"created_at":"2024-08-01T20:01:00.396Z","updated_at":"2025-04-07T05:34:12.172Z","avatar_url":"https://github.com/mholt.png","language":"Go","readme":"Caddy embedded file system\n===========================\n\nThis Caddy plugin embeds your site directly into your web server's binary.\n\n**NOTE:** This plugin requires building Caddy from source on your own machine because you need to add your own content to the `files` directory before compiling. The `go` command is _required_ and I recommend using [`xcaddy`](https://github.com/caddyserver/xcaddy) to build. You cannot download this plugin from the Caddy website, for example, and expect it to have your site embedded within it.\n\n\u003e [!NOTE]\n\u003e This is not an official repository of the [Caddy Web Server](https://github.com/caddyserver) organization.\n\n## Instructions\n\n1. Clone this repo: `git clone https://github.com/mholt/caddy-embed.git \u0026\u0026 cd caddy-embed`\n2. Replace the contents of the `files` subfolder with your site.\n3. Build Caddy with your locally-cloned copy of this plugin: `xcaddy build --with github.com/mholt/caddy-embed=.`\n\nNow wherever your server goes, your site goes with it. Serve it up like this:\n\n```\nexample.com\n\nfile_server {\n\tfs embedded\n}\n```\n\nYou can customize the `//go:embed` directive in the source before building if you want to choose other files or folders to embed. See the [Go `embed` package docs](https://pkg.go.dev/embed).\n\n## Site root\n\nSomewhat annoyingly, when you use `//go:embed` to add a folder, Go embeds the folder to the root of the virtual file system, without a way to configure Go to add its _contents_ to the root. Because our directive is `//go:embed files`, that means all filenames have to be prefixed with `files/`. This is unintuitive as you would expect your site root, for example, to be at `index.html`, not `files/index.html`.\n\nTo counter this behavior, this module automatically [\"subs the FS\"](https://pkg.go.dev/io/fs#Sub) to trim that top-level folder prefix as long as the embedded directory is named `files`, and it is not moved or renamed by you.\n\nI would recommend simply doing as the instructions say, and putting your content into the `files` folder. You can put multiple folders in there if you want more than one. But you are always welcome to do your own thing and change the go:embed directive, etc. If you do that, the automatic prefix stripping won't work for you.\n\nIf you are using `file_server` and want to have the contents of a top-level folder be accessed from the root of the file system, _and if you customize the //go:embed directive_, you can still strip the root folder name like this:\n\n```\nfile_server {\n\tfs embedded\n\troot myfolder\n}\n```\n\nwhere `myfolder` is the name of the folder you added to the `go:embed` directive. **This is only applicable if you are customizing the //go:embed directive and want to strip the top-level folder from the path.**\n\nIn summary: For most people, this module will \"just work\" and you do not need to set or change the site root.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmholt%2Fcaddy-embed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmholt%2Fcaddy-embed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmholt%2Fcaddy-embed/lists"}