{"id":16744010,"url":"https://github.com/goccy/rebirth","last_synced_at":"2025-03-21T22:31:38.729Z","repository":{"id":57503717,"uuid":"228358868","full_name":"goccy/rebirth","owner":"goccy","description":"Supports live reloading for Go","archived":false,"fork":false,"pushed_at":"2020-08-05T02:09:46.000Z","size":422,"stargazers_count":71,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-18T05:35:05.341Z","etag":null,"topics":["docker","go","golang","golang-application","golang-cli","live-reload"],"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/goccy.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}},"created_at":"2019-12-16T10:14:33.000Z","updated_at":"2025-02-03T14:24:10.000Z","dependencies_parsed_at":"2022-08-28T02:00:45.482Z","dependency_job_id":null,"html_url":"https://github.com/goccy/rebirth","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Frebirth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Frebirth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Frebirth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Frebirth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goccy","download_url":"https://codeload.github.com/goccy/rebirth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880262,"owners_count":20525505,"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","go","golang","golang-application","golang-cli","live-reload"],"created_at":"2024-10-13T01:42:13.897Z","updated_at":"2025-03-21T22:31:38.405Z","avatar_url":"https://github.com/goccy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rebirth [![Actions Status](https://github.com/goccy/rebirth/workflows/Go/badge.svg)](https://github.com/goccy/rebirth/actions)\nSupports live reloading for Go\n\n![go_rebirth](https://user-images.githubusercontent.com/209884/71393497-2ba9aa00-2650-11ea-90ca-5c6b1dd0df7e.png)\n\n# Features\n\n- Better features than github.com/pilu/fresh\n- Supports cross compile and live reloading on host OS for `docker` users ( **Very Fast** for `Docker for Mac` user )\n- Supports cross compile by cgo ( C/C++ ) ( currently, works on macOS ( and target architecture is `amd64` ) only )\n- Supports helper commands for `go run` `go test` `go build`\n\n# Synopsis\n\n## Settings\n\n`rebirth` needs configuration file ( `rebirth.yml` ) to running .\n`rebirth init` create it .\n\n`rebirth.yml` example is the following.\n\n```yaml\ntask:\n  migrate:\n    desc: migrate schema\n    commands:\n      - mysql ....\nhost:\n  docker: container_name\nbuild:\n  main: path/to/main.go # change path to main package ( default: . )\n  init:\n    - echo 'init hook' # called once at starting\n  before:\n    - echo 'before hook' # called before build\n  after:\n    - echo 'after hook' # called after build\n  env:\n    CGO_LDFLAGS: /usr/local/lib/libz.a\nrun:\n  env:\n    RUNTIME_ENV: \"fuga\"\nwatch:\n  root: . # root directory for watching ( default: . )\n  ignore:\n    - vendor\n```\n\n- `task` : define custom command\n- `host` : specify host information for running to an application ( currently, supports `docker` only )\n- `build` : specify ENV variables for building\n- `run` : specify ENV variables for running\n- `watch` : specify `root` directory or `ignore` directories for watching go file\n\n## In case of running on localhost\n\n### 1. Install `rebirth` CLI\n\n```bash\n$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth\n```\n\n### 2. Create `rebirth.yml`\n\n```bash\n$ rebirth init\n```\n\n### 3. Run `rebirth`\n\n```bash\nrebirth\n```\n\n## In case of running with Docker for Mac\n\nExample tree\n\n```\n.\n├── docker-compose.yml\n├── main.go\n└── rebirth.yml\n```\n\n`main.go` is your web application's source.\n\n### 1. Install `rebirth` CLI\n\n```bash\n$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth\n```\n\n### 2. Install cross compiler for cgo\n\n```bash\n$ brew install FiloSottile/musl-cross/musl-cross\n```\n\n### 3. Write settings\n\n### docker-compose.yml\n\n```yaml\nversion: '2'\nservices:\n  app:\n    image: golang:1.13.5\n    container_name: rebirth_app\n    volumes:\n      - '.:/go/src/app'\n    working_dir: /go/src/app\n    environment:\n      GO111MODULE: \"on\"\n    command: |\n      tail -f /dev/null\n```\n\n### rebirth.yml\n\n```yaml\nhost:\n  docker: rebirth_app # container_name in docker-compose.yml\n```\n\n### 4. Run `rebirth`\n\n```bash\n$ rebirth\n\n# start live reloading !!\n\n# build for docker container's architecture on macOS (e.g. GOOS=linux GOARCH=amd64\n# execute built binary on target container\n```\n\n## Helper commands\n\n```bash\nUsage:\n  rebirth [OPTIONS] \u003ccommand\u003e\n\nHelp Options:\n  -h, --help  Show this help message\n\nAvailable commands:\n  build  execute 'go build' command\n  init   create rebirth.yml for configuration\n  run    execute 'go run'   command\n  test   execute 'go test'  command\n```\n\n### `rebirth build`\n\nHelp cross compile your go script\n\n```bash\n$ rebirth build -o app script/hoge.go\n```\n\n### `rebirth test`\n\nHelp cross compile for `go test`\n\n```bash\n$ rebirth test -v ./ -run Hoge\n```\n\n### `rebirth run`\n\nHelp cross compile for `go run`\n\n```bash\n$ rebirth run script/hoge.go\n```\n\n\n# How it Works\n\n`~/work/app` directory is mounted on the container as `/go/src/app`\n\n\u003cimg width=\"600px\" src=\"https://user-images.githubusercontent.com/209884/71261949-f7996500-2381-11ea-9b18-a8e4dfd49c41.png\"\u003e\u003c/img\u003e\n\n1. install `rebirth` CLI ( `GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth` )\n2. run `rebirth` and it cross compile myself for Linux ( GOOS=linux, GOARCH=amd64 ) and put it to `.rebirth` directory as `__rebirth`\n3. copy `.rebirth/__rebirth` to the container ( `.rebirth` directory is mounted on the container )\n4. watch `main.go` ( by [fsnotify](https://github.com/fsnotify/fsnotify) )\n\n\u003cimg width=\"500px\" src=\"https://user-images.githubusercontent.com/209884/71261979-05e78100-2382-11ea-8955-91e5b01f0234.png\"\u003e\u003c/img\u003e\n\n5. cross compile `main.go` for Linux and put to `.rebirth` directory as `program`\n6. copy `.rebirth/program` to the container\n\n\u003cimg width=\"600px\" src=\"https://user-images.githubusercontent.com/209884/71357811-3883ba80-25ca-11ea-9e92-b4cec89e9c95.png\"\u003e\u003c/img\u003e\n\n7. run `__rebirth` on the container\n8. `__rebirth` executes `program` \n9. edit `main.go`\n10. `rebirth` detects file changed event\n\n\u003cimg width=\"500px\" src=\"https://user-images.githubusercontent.com/209884/71261992-0b44cb80-2382-11ea-9e1d-a2c44f0262ae.png\"\u003e\u003c/img\u003e\n\n11. cross compile `main.go` for Linux and put to `.rebirth` directory as `program`\n12. copy `.rebirth/program` to the container\n13. `rebirth` send signal to `__rebirth` for reloading ( `SIGHUP` )\n14. `__rebirth` kill the current application and execute `program` as a new application\n\n# License\n\nMIT\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoccy%2Frebirth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoccy%2Frebirth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoccy%2Frebirth/lists"}