- Go 80.4%
- HTML 12.6%
- CSS 3.4%
- JavaScript 3.2%
- Mustache 0.4%
🍉 MelonBook
Guestbook-as-a-service software powering GuestMelon. Free to use, or selfhostable if you want even more control (but please note licensing restrictions).
Usage
You don't need to download or install anything unless you're developing MelonBook or deploying your own selfhosted copy (in which case, see below).
If you just want a MelonBook-powered guestbook, you can get one for free at: GuestMelon.com
Development
Dependencies and configuration
Requires Go.
Copy .env.example to .env and configure to your liking.
Running locally
Run with go run .. Build with go build ..
If you're developing actively, you might like to use gow for rapid reloads on code change. To do this, install with e.g. go install github.com/mitranim/gow@latest and then run with gow -e=go,mod,html,env,css,js,sql,mustache run ..
(削除) To set up a proxy on port 80 (required to use Melonland Passport authentication, which doesn't support unusual ports), run (this is no longer needed; Melonland Passport has been enhanced)caddy run --config Caddyfile. You might like to add to your hostsfile (e.g. /etc/hosts) something like 127.0.0.1 localhost alpha.localhost beta.localhost gamma.localhost delta.localhost etc. so you can test guestbook subdomains. (削除ここまで)
Optional dependencies
For IP-to-Country tracking, download MaxMind's free "GeoLite Country" database GeoLite2-Country.mmdb and place in the application directory.
Deployment
To deploy to a live server, follow the development configuration instructions, but also consider the following:
Deployment webserver
Here's a sample Caddy configuration to get you started, including appropriate CORS configuration and wildcard DNS (assuming Namecheap, but you can adapt to whichever DNS-01 friendly route to TLS certificate provision that you prefer):
# All other guestmelon.com / *.guestmelon.com addresses are handled by the application
guestmelon.com {
reverse_proxy localhost:8080
}
*.guestmelon.com {
tls {
dns namecheap {
api_key {env.NAMECHEAP_API_KEY}
user {env.NAMECHEAP_USERNAME}
api_endpoint https://api.namecheap.com/xml.response
client_ip {env.LOCAL_IP}}
}
}
header {
Access-Control-Allow-Origin "*"
}
reverse_proxy localhost:8080
}
### Automatic deployments
Automatic deployments from a branch of your choice can be facilitated via Webhook, with e.g. Caddy:
# Webhook handling for auto-redeployment
webhook.guestmelon.com {
reverse_proxy localhost:9000
}
and webhook.conf (this one listens for pushes to main and pulls):
[
{
"id": "codeberg-push",
"execute-command": "[YOUR_CHECKOUT_SCRIPT]",
"command-working-directory": "[YOUR_CONTAINER_DIR]",
"pass-arguments-to-command": [
{
"source": "string",
"name": "main"
}
],
"trigger-rule": {
"and": [
{
"match": {
"type": "payload-hash-sha256",
"secret": "[YOUR_CODEBERG_SECRET]",
"parameter": {
"source": "header",
"name": "X-Hub-Signature-256"
}
}
},
{
"match": {
"type": "value",
"value": "refs/heads/main",
"parameter": {
"source": "payload",
"name": "ref"
}
}
}
]
}
}
]
Your checkout script should pull the latest code and restart the application. On which note:
Persistent application
Go runs tidily as a system service. Here's a possible /etc/systemd/system/guestmelon.service for Debian 13 which does its own compilation pre-run:
[Unit]
[Install]
WantedBy=multi-user.target
[Service]
ExecStart=go run .
WorkingDirectory=[YOUR APPLICATION DIRECTORY]
User=guestmelon
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
SyslogIdentifier=%n
License
The code is licensed under the AGPLv3. Broadly-speaking, this means that you can use it for any purpose you like, so long as you sharealike; note that this includes the requirement that you make any modified source code available if you host your own copy.