feat: dev hot reload setup

This commit is contained in:
Nicolas Meienberger
2025-08-09 17:08:54 +02:00
parent e7463d34ef
commit 065c629ba8
11 changed files with 88 additions and 3 deletions

52
.air.toml Normal file
View File

@@ -0,0 +1,52 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "out"
[build]
args_bin = []
bin = "./out/main"
cmd = "go build -o ./out/main ."
delay = 1000
exclude_dir = ["assets", "out", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
silent = false
time = false
[misc]
clean_on_exit = false
[proxy]
app_port = 0
enabled = false
proxy_port = 0
[screen]
clear_on_rebuild = false
keep_scroll = true

1
.gitignore vendored
View File

@@ -31,3 +31,4 @@ go.work.sum
# .idea/
# .vscode/
ironmount
out/

12
Dockerfile.dev Normal file
View File

@@ -0,0 +1,12 @@
FROM golang:1.24-alpine3.21 AS builder
WORKDIR /ironmount
RUN go install github.com/air-verse/air@latest
COPY go.mod ./
RUN go mod download
COPY . .
CMD ["air", "-c", ".air.toml"]

View File

@@ -1 +1,3 @@
# ironmount
mutagen sync create ~/Developer/ironmount nicolas@192.168.2.220:/home/nicolas/ironmount

View File

@@ -4,9 +4,13 @@ services:
ironmount:
build:
context: .
dockerfile: Dockerfile
dockerfile: Dockerfile.dev
container_name: ironmount
restart: unless-stopped
volumes:
- ./:/ironmount
- /run/docker/plugins:/run/docker/plugins
- /tmp/ironmount:/tmp/ironmount
environment:
- GO_ENV=development

View File

@@ -7,7 +7,6 @@ import (
)
func Activate(w http.ResponseWriter, r *http.Request) {
// Log the activation request
log.Printf("Received activation request: %s", r.URL.Path)
resp := map[string]any{

View File

@@ -3,12 +3,15 @@ package driver
import (
"encoding/json"
"ironmount/internal/constants"
"log"
"net/http"
"os"
"path/filepath"
)
func Create(w http.ResponseWriter, r *http.Request) {
log.Printf("Received create request: %s", r.URL.Path)
var req struct {
Name string
}

View File

@@ -2,10 +2,13 @@ package driver
import (
"encoding/json"
"log"
"net/http"
)
func Mount(w http.ResponseWriter, r *http.Request) {
log.Printf("Received mount request: %s", r.URL.Path)
var req MountRequest
err := json.NewDecoder(r.Body).Decode(&req)

View File

@@ -2,10 +2,13 @@ package driver
import (
"encoding/json"
"log"
"net/http"
)
func Path(w http.ResponseWriter, r *http.Request) {
log.Printf("Received path request: %s", r.URL.Path)
var req PathRequest
_ = json.NewDecoder(r.Body).Decode(&req)

View File

@@ -2,10 +2,13 @@ package driver
import (
"encoding/json"
"log"
"net/http"
)
func Remove(w http.ResponseWriter, r *http.Request) {
log.Printf("Received remove request: %s", r.URL.Path)
var req RemoveRequest
_ = json.NewDecoder(r.Body).Decode(&req)

View File

@@ -2,9 +2,12 @@ package driver
import (
"encoding/json"
"log"
"net/http"
)
func Unmount(w http.ResponseWriter, r *http.Request) {
log.Printf("Received unmount request: %s", r.URL.Path)
_ = json.NewEncoder(w).Encode(map[string]string{"Err": ""})
}