haydenwoodhead / burner.kiwi

No bullshit temporary mail service written in Go
https://burner.kiwi
MIT License
216 stars 26 forks source link

Linux ARM64 Build & Deploy guide #28

Open mrbluecoat opened 2 years ago

mrbluecoat commented 2 years ago

This took me a while to figure out so in case it helps others, here are the steps I used to build on an ARM64 device:

sudo apt update && sudo apt install -y curl tar git sqlite3 make

# burner.kiwi requires go >= 1.16
cd /tmp
curl -O -J -L https://go.dev/dl/go1.17.6.linux-arm64.tar.gz
tar -C /usr/local -xzf go*linux-arm64.tar.gz
export PATH=$PATH:/usr/local/go/bin
echo 'export PATH=$PATH:/usr/local/go/bin' > /etc/profile.d/go_path.sh
go version

cd /tmp
git clone https://github.com/golangci/golangci-lint.git
cd golangci-lint
bash install.sh
mv bin/golangci-lint /usr/local/bin

cd /tmp
git clone https://github.com/tdewolff/minify.git
cd minify/cmd/minify
go build
mv minify /usr/local/bin

cd /tmp
git clone https://github.com/haydenwoodhead/burner.kiwi.git
cd burner.kiwi
sed -i 's/GOOS=linux GOARCH=amd64 //g' Makefile
make build-sqlite
mv burnerkiwi /usr/local/bin
mrbluecoat commented 2 years ago

It also took me a while to figure out it runs on port 8080 by default, which makes sense for TLS termination with a proxy. Here's how to do it with NGINX (replace yourdomain.com with the correct value):

sudo apt install -y nginx
cat > /etc/nginx/sites-enabled/default <<EOF
server {
    server_name yourdomain.com;
    location / {
        proxy_pass http://localhost:8080;
    }
}
EOF
sudo systemctl reload nginx

sudo apt install -y snapd
sudo snap install core; sudo snap refresh core
sudo apt remove -y certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx
haydenwoodhead commented 2 years ago

Thanks @mrbluecoat really appreciate you providing these details. Self hosting has always been a bit of a secondary priority for this project but I should probably write some more docs and provide some pre-built binaries. I'll add the port to the readme as that's quite important.

mrbluecoat commented 2 years ago

Last step is the service to survive a reboot (replace YOUR_SECRET_HERE and yourdomain.com):

mkdir /opt/burnerkiwi
touch /opt/burnerkiwi/burnerkiwi.db

cat > /opt/burnerkiwi/burnerkiwi.config <<EOF
KEY='YOUR_SECRET_HERE'
WEBSITE_URL='yourdomain.com'
STATIC_URL='/static'
EMAIL_TYPE='smtp'
DB_TYPE='sqlite3'
DATABASE_URL='/opt/burnerkiwi/burnerkiwi.db'
EOF

cat > burnerkiwi.service <<EOF
[Unit]
Description=Burner.Kiwi Service

[Service]
Restart=always
RestartSec=1
EnvironmentFile=/opt/burnerkiwi/burnerkiwi.config
ExecStart=/usr/local/bin/burnerkiwi

[Install]
WantedBy=default.target
EOF

sudo mv burnerkiwi.service /etc/systemd/system/

systemctl start burnerkiwi.service
systemctl status burnerkiwi.service
systemctl enable burnerkiwi.service
KvizadSaderah commented 2 years ago

could you please make a step by step guidance for simple ubuntu/debian vps? i break my head to make it work, and failed