add native installation support

This commit is contained in:
Akhil Gupta
2021-06-03 19:07:24 +05:30
parent 9a262e6e95
commit cca55d2838
2 changed files with 146 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ Hammond is a self hosted vehicle management system to track fuel and other expen
_Developers Note: This project is under active development which means I release new updates very frequently. It is recommended that you use something like [watchtower](https://github.com/containrrr/watchtower) which will automatically update your containers whenever I release a new version or periodically rebuild the container with the latest image manually._
__Also check out my other self-hosted, open-source solution - [Podgrab](https://github.com/akhilrex/podgrab) - Podcast download and archive manager and player.__
### Motivation and Developer Notes
I was looking for a fuel tracking system and stumbled upon Clarkson. Although it did most of what I needed it has not been updated for quite a lot of time. Since I had some bandwidth available as my previous open source project [Podgrab](http://github.com/akhilrex/podgrab) had become quite stable now, my first thought was to contribute to the Clarkson project only. I soon realized that the architecture that Clarkson had used was not really be that extensible now and would warrant a complete rewrite only. So I decided to build Hammond - The successor to Clarkson.
@@ -118,11 +119,11 @@ services:
docker-compose up -d
```
<!-- ### Build from Source / Ubuntu Installation
### Build from Source / Ubuntu Installation
Although personally I feel that using the docker container is the best way of using and enjoying something like hammond, a lot of people in the community are still not comfortable with using Docker and wanted to host it natively on their Linux servers. Follow the link below to get a guide on how to build hammond from source.
[Build from source / Ubuntu Guide](docs/ubuntu-install.md) -->
[Build from source / Ubuntu Guide](docs/ubuntu-install.md)
### Environment Variables

143
docs/ubuntu-install.md Normal file
View File

@@ -0,0 +1,143 @@
# Building from source / Ubuntu Installation Guide
Although personally I feel that using the docker container is the best way of using and enjoying something like Hammond, a lot of people in the community are still not comfortable with using Docker and wanted to host it natively on their Linux servers.
This guide has been written with Ubuntu in mind. If you are using any other flavour of Linux and are decently competent with using command line tools, it should be easy to figure out the steps for your specific distro.
## Install Go and Node
Hammond is built using Go and VueJS which means GO and Node would be needed to compile and build the source code. Hammond is written with Go 1.15/ Node v14 so any version equal to or above this should be good to go.
If you already have Go and Node installed on your machine, you can skip to the next step.
Get precise Go installation process at the official link here - https://golang.org/doc/install
Get precise Node installation process at the official link here - https://nodejs.org/en/
Following steps will only work if Go and Node are installed and configured properly.
## Install dependencies
``` bash
sudo apt-get install -y git ca-certificates ufw gcc
```
## Clone from Git
``` bash
git clone --depth 1 https://github.com/akhilrex/hammond
```
## Build and Copy dependencies
``` bash
cd hammond/server
mkdir -p ./dist
cp .env ./dist
go build -o ./dist/hammond ./main.go
```
## Create final destination and copy executable
``` bash
sudo mkdir -p /usr/local/bin/hammond
mv -v dist/* /usr/local/bin/hammond
mv -v dist/.* /usr/local/bin/hammond
```
## Building the UI
Go back to the root of the hammond folder.
``` bash
cd ui
npm install
npm run build
mv dist /usr/local/bin/hammond
```
At this point theoretically the installation is complete. You can make the relevant changes in the ```.env``` file present at ```/usr/local/bin/hammond``` path and run the following command
``` bash
cd /usr/local/bin/hammond && ./hammond
```
Point your browser to http://localhost:3000 (if trying on the same machine) or http://server-ip:3000 from other machines.
If you are using ufw or some other firewall, you might have to make an exception for this port on that.
## Setup as service (Optional)
If you want to run Hammond in the background as a service or auto-start whenever the server starts, follow the next steps.
Create new file named ```hammond.service``` at ```/etc/systemd/system``` and add the following content. You will have to modify the content accordingly if you changed the installation path in the previous steps.
``` unit
[Unit]
Description=Hammond
[Service]
ExecStart=/usr/local/bin/hammond/hammond
WorkingDirectory=/usr/local/bin/hammond/
[Install]
WantedBy=multi-user.target
```
Run the following commands
``` bash
sudo systemctl daemon-reload
sudo systemctl enable hammond.service
sudo systemctl start hammond.service
```
Run the following command to check the service status.
``` bash
sudo systemctl status hammond.service
```
# Update Hammond
In case you have installed Hammond and want to update the latest version (another area where Docker really shines) you need to repeat the steps from cloning to building and copying.
Stop the running service (if using)
``` bash
sudo systemctl stop hammond.service
```
## Clone from Git
``` bash
git clone --depth 1 https://github.com/akhilrex/hammond
```
## Build and Copy dependencies
``` bash
cd hammond
mkdir -p ./dist
cp .env ./dist
go build -o ./dist/hammond ./main.go
```
## Create final destination and copy executable
``` bash
sudo mkdir -p /usr/local/bin/hammond
mv -v dist/* /usr/local/bin/hammond
```
Go back to the root of the hammond folder.
``` bash
cd ui
npm install
npm run build
mv dist /usr/local/bin/hammond
```
Restart the service (if using)
``` bash
sudo systemctl start hammond.service
```