{"id":20628211,"url":"https://github.com/huakunshen/wol-web","last_synced_at":"2025-04-10T01:07:13.281Z","repository":{"id":44696499,"uuid":"347510083","full_name":"HuakunShen/wol-web","owner":"HuakunShen","description":"Wakeonlan Web App built with golang, sveltekit and pocketbase","archived":false,"fork":false,"pushed_at":"2025-02-11T22:21:03.000Z","size":2020,"stargazers_count":71,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T01:07:07.829Z","etag":null,"topics":["golang","pocketbase","svelte","sveltekit"],"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/HuakunShen.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},"funding":null},"created_at":"2021-03-14T00:29:27.000Z","updated_at":"2025-04-07T16:25:19.000Z","dependencies_parsed_at":"2024-06-19T01:53:37.166Z","dependency_job_id":"bb772fa0-cb1b-46b8-8ef2-a46ca1defcf8","html_url":"https://github.com/HuakunShen/wol-web","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuakunShen%2Fwol-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuakunShen%2Fwol-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuakunShen%2Fwol-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuakunShen%2Fwol-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HuakunShen","download_url":"https://codeload.github.com/HuakunShen/wol-web/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137887,"owners_count":21053775,"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":["golang","pocketbase","svelte","sveltekit"],"created_at":"2024-11-16T13:19:31.932Z","updated_at":"2025-04-10T01:07:13.255Z","avatar_url":"https://github.com/HuakunShen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wol-web\n\n\u003e A web app hosted locally for wakeonlan\n\u003e\n\u003e This is a rewrite with sveltekit + PocketBase to replace the old version I wrote a few years ago\n\u003e\n\u003e In the new rewrite, instead of writing an entire rest API server and manage database with gorm, I use PocketBase as backend and database. Its golang extension feature allows me to add the wakeonlan feature easily. The most complicated part, Auth, is also fully handled by PocketBase, saving lots of time. PocketBase also has a built-in database management UI, making user creation/management much easier.\n\n![](https://i.imgur.com/2pGGr1Z.png)\n\n## Deployment (Docker)\n\nDeployment with docker is super simple.\n\nDocker image [`huakunshen/wol`](https://hub.docker.com/repository/docker/huakunshen/wol/) is available on docker hub.\n\nBoth `linux/amd64` and `linux/arm64` are supported.\n\n\u003e [!IMPORTANT]\n\u003e 1. The container must be in the same network as the target hosts\n\u003e 2. The container must be started with `--network=host`\n\u003e 3. Mac doesn't support `--network=host` with docker. On Mac you have to run server with go directly. It's recommended to use linux.\n\n### Step 1: Start Server\n\nHere is a full command to start the server with a superuser initialized\n\n```bash\ndocker run --rm \\\n  --network=host \\\n  -e PORT=8090 \\\n  -e SUPERUSER_EMAIL=\u003croot@example.com\u003e \\\n  -e SUPERUSER_PASSWORD=\u003cyour password\u003e \\\n  -v ./pb_data:/app/pb_data \\\n  huakunshen/wol:latest\n```\n\n- In this example I used `--rm` to clean up the container after it's closed for demo purpose\n- In production, you should replace `--rm` with `-d` to run it in detach mode\n\nThe 2 environment variables and volume are optional but recommended.\n\n- The volume is for data persistence, so you don't lose your data after container is destroyed.\n  - Instead of using a local directory, it's better to create a volume and bind to it.\n- `PORT` environment variable is used to specify the port the server listens on\n  - Default is 8090\n  - Since this app has to be run in host network, you can't set port mapping with `-p` option; thus the `PORT` environment variable can be used to change the port.\n- The 2 environment variables are used to create an initial superuser in database\n  - This project uses pocketbase as its backend and database, there is no user register feature as we shouldn't allow random person to register and send magic packets in your network. The only way to create user is log into pocketbase admin console with a superuser account and manually create user in the `users` collection/table.\n  - When both `SUPERUSER_EMAIL` and `SUPERUSER_PASSWORD` are set, the server will create this superuser the first time it starts and you could login directly.\n  - If you didn't set initial superuser credentials, you could also create a superuser\n    - A long URL should be printed to console, open it in browser. The token in the URL allows you to create a superuser\n    ```\n    (!) Launch the URL below in the browser if it hasn't been open already to create your first superuser account:\n    http://0.0.0.0:8090/_/#/pbinstal/eyJhbGciOiJIUzI1NiIs...\n    ```\n    - If you ran `docker run -d` in detach mode, run `docker logs \u003ccontainer name\u003e` to find the long URL for superuser creation.\n\n### Step 2: Create a Regular User\n\nThe superuser we discussed previously is like a database admin, you need to create a regular user to login to the website.\n\n1. Go to [`http://localhost:8090/_/`](http://localhost:8090/_/) (or the url of your environment), login with superuser credentials\n2. Go to `users` collection, create a user, remember your email and password\n\n### Step 3: Login to WOL Web\n\nYou can go to `http://localhost:8090/auth` and login with your regular user credentials.\n\nCreate a host then you can wake up your computer from browser.\n\n## Deployment (docker compose)\n\nDocker compose makes creating and destroying wol container easier. \n\nA [compose.yml](./compose.yml) is provided in this repo.\n\n```yaml\nservices:\n  wol:\n    image: \"huakunshen/wol\"\n    container_name: wol-web\n    network_mode: host\n    volumes:\n      - wol_data:/app/pb_data\n    environment:\n      - SUPERUSER_EMAIL=root@example.com\n      - SUPERUSER_PASSWORD=changeme\n      - PORT=8090\nvolumes:\n  wol_data:\n```\n\n```bash\ndocker compose up\ndocker compose down\n```\n\n## Develop\n\n**Prerequisite:**\n1. Bun\n2. Golang\n\nbun workspace is used to manage this monorepo, `dev` script will start frontend and backend together.\n\n```bash\nbun install\nbun run dev # start both sveltekit dev server and golang pocketbase server\n```\n\n### Server\n\nThe golang server is in `apps/server`. It's a golang pocketbase extension with some custom routes.\n\n```bash\nair # start development\ngo run main.go serve # start the server without hot reload\n```\n\n#### Migrations\n\nWhen table is modified, run `go run . migrate collections` to generate a migration `.go` file that will be auto loaded.\n\n\n### Frontend\n\nThe frontend is in `apps/web`, written with sveltekit + `@sveltejs/adapter-static`.\n\nIn development, use `http://localhost:5173`. \n\nRunning `bun run build` will generate a `apps/web/build` directory, \nand will be automatically copied to `apps/server/pb_public` ready to be served directly by the golang server as static assets.\n\nIn production the website is accesssible at `http://localhost:8090/`.\n\n### Docker\n\n`make buildx` automatically builds docker image for `linux/amd64` and `linux/arm64` and push to dockerhub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuakunshen%2Fwol-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuakunshen%2Fwol-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuakunshen%2Fwol-web/lists"}