187 lines
5.5 KiB
Markdown
187 lines
5.5 KiB
Markdown
# Coolify Deployment Guide
|
|
|
|
This guide explains how to deploy the Linux Service website to your self-hosted Coolify instance with automatic updates from your Gitea repository.
|
|
|
|
## Prerequisites
|
|
|
|
- Coolify installed and running
|
|
- Access to your Gitea instance (gitea.boner.be)
|
|
- Domain name configured for your service
|
|
|
|
## Environment Variables
|
|
|
|
The application supports the following environment variables:
|
|
|
|
| Variable | Default Value | Description |
|
|
|----------|---------------|-------------|
|
|
| `PORT` | `8080` | Port the application listens on |
|
|
| `COMPANY_NAME` | `Hogeland Linux` | Company name displayed on the website |
|
|
| `KVK` | `12345678` | KVK number for contact information |
|
|
| `EMAIL` | `info@hogelandlinux.nl` | Contact email address |
|
|
| `PHONE` | `+31 6 12345678` | Contact phone number |
|
|
| `STREET` | `Voorstraat 123` | Street address |
|
|
| `POSTAL_CODE` | `9967 AA` | Postal code |
|
|
| `VILLAGE` | `Eenrum` | Village/city name |
|
|
| `DOMAIN` | `hogelandlinux.nl` | Your website domain (used for SEO and social media meta tags) |
|
|
| `TELEGRAM_BOT_TOKEN` | *(empty)* | Telegram bot token for contact form notifications |
|
|
| `TELEGRAM_CHAT_ID` | *(empty)* | Telegram chat ID where notifications will be sent |
|
|
|
|
## Telegram Integration Setup (Optional)
|
|
|
|
The contact form can send notifications to a Telegram chat. To set this up:
|
|
|
|
### 1. Create a Telegram Bot
|
|
|
|
1. Message [@BotFather](https://t.me/BotFather) on Telegram
|
|
2. Send `/newbot` command
|
|
3. Follow the instructions to create your bot
|
|
4. Copy the bot token (looks like `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`)
|
|
|
|
### 2. Get Your Chat ID
|
|
|
|
1. Add your bot to the chat where you want notifications
|
|
2. Send a message to the bot in that chat
|
|
3. Visit `https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates`
|
|
4. Look for the `chat.id` field in the response
|
|
5. Copy the chat ID (can be positive or negative number)
|
|
|
|
### 3. Configure Environment Variables
|
|
|
|
Set the following environment variables in your deployment:
|
|
|
|
```bash
|
|
TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
|
|
TELEGRAM_CHAT_ID=123456789
|
|
```
|
|
|
|
**Note:** If these variables are not set, the contact form will still work but won't send Telegram notifications.
|
|
|
|
## Coolify Deployment Steps
|
|
|
|
### 1. Create New Resource in Coolify
|
|
|
|
1. Open your Coolify dashboard
|
|
2. Click "New Resource"
|
|
3. Select "Public Repository" or "Private Repository" (if your Gitea repo is private)
|
|
|
|
### 2. Configure Repository
|
|
|
|
**Repository URL:** `https://gitea.boner.be/[your-username]/[repository-name]`
|
|
|
|
**Branch:** `master`
|
|
|
|
**Build Pack:** `Docker`
|
|
|
|
### 3. Configure Build Settings
|
|
|
|
- **Dockerfile Location:** `./Dockerfile`
|
|
- **Build Context:** `.`
|
|
- **Ports:** `8080`
|
|
|
|
### 4. Set Environment Variables
|
|
|
|
In the Coolify environment variables section, add:
|
|
|
|
```
|
|
PORT=8080
|
|
COMPANY_NAME=Hogeland Linux
|
|
KVK=12345678
|
|
EMAIL=info@hogelandlinux.nl
|
|
PHONE=+31 6 12345678
|
|
STREET=Voorstraat 123
|
|
POSTAL_CODE=9967 AA
|
|
VILLAGE=Eenrum
|
|
DOMAIN=hogelandlinux.nl
|
|
TELEGRAM_BOT_TOKEN=your_bot_token_here
|
|
TELEGRAM_CHAT_ID=your_chat_id_here
|
|
```
|
|
|
|
**Note:** The Telegram variables are optional. If not set, the contact form will work but won't send notifications.
|
|
|
|
### 5. Configure Domain
|
|
|
|
- Set your desired domain/subdomain
|
|
- Coolify will automatically handle SSL certificate generation
|
|
|
|
### 6. Enable Auto-Deploy
|
|
|
|
1. Go to the "Settings" tab of your application
|
|
2. Enable "Auto Deploy"
|
|
3. Set the branch to `master`
|
|
4. Configure webhook URL in your Gitea repository
|
|
|
|
### 7. Gitea Webhook Configuration
|
|
|
|
To enable automatic deployments when you push to master:
|
|
|
|
1. Go to your repository on gitea.boner.be
|
|
2. Navigate to Settings → Webhooks
|
|
3. Click "Add Webhook" → "Gitea"
|
|
4. Set the Payload URL to your Coolify webhook URL (found in your app settings)
|
|
5. Set Content Type to `application/json`
|
|
6. Select "Just the push event"
|
|
7. Check "Active"
|
|
8. Click "Add Webhook"
|
|
|
|
## Docker Commands for Local Testing
|
|
|
|
```bash
|
|
# Build the image
|
|
docker build -t linuxservice .
|
|
|
|
# Run locally
|
|
docker run -p 8080:8080 \
|
|
-e COMPANY_NAME="Hogeland Linux" \
|
|
-e EMAIL="info@hogelandlinux.nl" \
|
|
linuxservice
|
|
|
|
# Or use docker-compose
|
|
docker-compose up --build
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Common Issues
|
|
|
|
1. **Build Fails**: Check that all files (templates/, static/) are committed to your repository
|
|
2. **Port Issues**: Ensure PORT environment variable matches the exposed port
|
|
3. **Template Errors**: Verify that templates directory is included in the Docker image
|
|
|
|
### Logs
|
|
|
|
Check application logs in Coolify dashboard under the "Logs" tab.
|
|
|
|
### Health Check
|
|
|
|
The application should respond to `GET /` with the homepage. You can check this endpoint to verify the deployment.
|
|
|
|
## File Structure
|
|
|
|
```
|
|
linuxservice/
|
|
├── Dockerfile # Container configuration
|
|
├── docker-compose.yml # Local development
|
|
├── .dockerignore # Docker build optimization
|
|
├── main.go # Go application
|
|
├── go.mod # Go module definition
|
|
├── static/ # Static assets (CSS, images, etc.)
|
|
│ └── style.css
|
|
├── templates/ # HTML templates
|
|
│ ├── index.html
|
|
│ └── contact.html
|
|
└── DEPLOYMENT.md # This file
|
|
```
|
|
|
|
## Performance Considerations
|
|
|
|
- The Docker image uses multi-stage builds for smaller size
|
|
- Static files are served directly by the Go application
|
|
- No external dependencies required
|
|
- Minimal resource usage (suitable for small VPS instances)
|
|
|
|
## Security Notes
|
|
|
|
- The application runs as a non-root user in the container
|
|
- Only port 8080 is exposed
|
|
- No sensitive data is stored in the application
|
|
- Environment variables should be used for configuration |