GW is a webserver that provides basic git functionalities via HTTP endpoints.
Motivation:
For small, single user web apps, I use text-based databases. For example, JSON,
or YAML files. Similarly, the accounting software that I use, beancount, is
also text-based. This has benefits like easy version control (simply using git)
and high fault tolerance (push to github). This app is a webserver that gives
you buttons to run git commit and git push so that those who use these web
apps don't have to open a terminal to backup their "database".
The most standard way to run this project is via docker (unless you're doing project development).
- Go to the folder that you want to run git commands from Web browser.
- Copy
.env.examplefrom this project repo and save it as.envinto your folder. - Copy
compose.yamlfrom this project repo and save it to your folder. - Update the environment variables as needed. See below on how to set a github token.
- Run
docker compose up. Add the-dflag at the end if you want run in detached mode. - Set the
restartflag in docker-compose.yaml toalwaysif this is a service to automatically start on system startup. - Visit localhost:8071 or whatever PORT, if you updated that in the environment file.
Check the sample .env.example file for what kinds of environment variables you can use.
- Clone this repo.
- Have go mentioned in
go.modor higher installed. - In the root directory of this project, run
go install . - Navigate to the folder that you want to expose through this server.
- Run
git initif this folder isn't a git repo already. - Create
.envfile in the root of this folder, mentioning the absolute path to this folder as value to the variableGW_REPO. - Optionally, set
HOSTandPORTenvironment variables as necessary. - Run
gw.
- Go to https://github.com/settings/personal-access-tokens/
- On the left sidebar, make sure "Fine-grained tokens" is selected.
- Click Generate New Token.
- Fill up the token name, description, fields etc.
- Set the expiration to "No expiration" or whatever you prefer.
- Select "Only select repository" and select the repo you want to give access to.
- On the bottom box, click on add permissions select "Contents"
- Give contents Read and Write access and save the token in the .env file in the
TOKENvariable.
By default, your server will listen on all interfaces meaning that others connected to the same network (Wifi) as you will be able to access your server by your IP:PORT web address. If you want to run only in localhost, change your PORT by prepending local IP as follows:
PORT=127.0.0.1:8063