Skip to content

Commit 43dcacd

Browse files
authored
refactor: caddyfile to json migration (#9)
1 parent 1f44280 commit 43dcacd

File tree

80 files changed

+16355
-9850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+16355
-9850
lines changed

.golangci.yml

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,53 @@ run:
44
timeout: 5m
55
modules-download-mode: readonly
66

7+
issues:
8+
max-issues-per-linter: 50
9+
max-same-issues: 10
10+
711
formatters:
812
enable:
13+
- gci
914
- gofmt
1015
- goimports
1116

1217
settings:
18+
gci:
19+
sections:
20+
- standard
21+
- default
22+
- prefix(github.com/aloks98/waygates)
23+
1324
gofmt:
1425
simplify: true
26+
1527
goimports:
1628
local-prefixes:
1729
- github.com/aloks98/waygates
1830

1931
linters:
2032
enable:
33+
# Core linters
2134
- errcheck
2235
- govet
2336
- ineffassign
2437
- staticcheck
2538
- unused
26-
- misspell
27-
- unconvert
28-
- gocritic
39+
40+
# Revive - comprehensive linter
2941
- revive
42+
43+
# Additional useful linters
44+
- bodyclose
45+
- copyloopvar
46+
- durationcheck
3047
- errorlint
48+
- gocritic
49+
- gosec
50+
- misspell
3151
- nilerr
3252
- prealloc
53+
- unconvert
3354

3455
settings:
3556
gocritic:
@@ -39,34 +60,60 @@ linters:
3960
disabled-checks:
4061
- hugeParam
4162
- unnecessaryDefer
63+
4264
revive:
65+
severity: warning
66+
confidence: 0.8
4367
rules:
68+
# Default revive rules
4469
- name: blank-imports
4570
- name: context-as-argument
4671
- name: context-keys-type
4772
- name: dot-imports
73+
- name: empty-block
74+
- name: error-naming
4875
- name: error-return
4976
- name: error-strings
50-
- name: error-naming
77+
- name: errorf
5178
- name: exported
52-
- name: if-return
5379
- name: increment-decrement
54-
- name: var-declaration
80+
- name: indent-error-flow
81+
- name: package-comments
5582
- name: range
5683
- name: receiver-naming
84+
- name: redefines-builtin-id
85+
- name: superfluous-else
5786
- name: time-naming
5887
- name: unexported-return
59-
- name: indent-error-flow
60-
- name: errorf
88+
- name: unreachable-code
89+
- name: unused-parameter
90+
- name: var-declaration
91+
- name: var-naming
92+
6193
staticcheck:
6294
checks:
6395
- all
6496
- -ST1000
6597
- -ST1005
6698
- -QF1003
99+
67100
misspell:
68101
locale: US
69102

70-
issues:
71-
max-issues-per-linter: 50
72-
max-same-issues: 10
103+
exclusions:
104+
presets:
105+
- std-error-handling
106+
- common-false-positives
107+
rules:
108+
- text: 'should have a package comment'
109+
linters: [ revive ]
110+
- text: 'exported \S+ \S+ should have comment( \(or a comment on this block\))? or be unexported'
111+
linters: [ revive ]
112+
- text: 'avoid meaningless package names'
113+
path: 'internal/utils/'
114+
linters: [ revive ]
115+
- path: '_test\.go'
116+
linters:
117+
- bodyclose
118+
- errcheck
119+
- gosec

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Waygates - Combined Backend + Caddy Container
33
# =============================================================================
44
# This Dockerfile creates a single container running both the Waygates backend
5-
# and Caddy server. The backend manages Caddy configuration via Caddyfiles.
5+
# and Caddy server. The backend manages Caddy configuration via JSON API.
66
#
77
# CUSTOMIZATION:
88
#
@@ -139,13 +139,10 @@ COPY --from=ui-builder /app/dist /app/ui
139139
COPY docker/entrypoint.sh /entrypoint.sh
140140
RUN chmod +x /entrypoint.sh
141141

142-
# Copy security snippets to /app/defaults
143-
# (NOT /etc/caddy which is a volume mount that gets overwritten)
144-
# Note: Caddyfile is generated dynamically by the backend based on CADDY_ACME_PROVIDER
145-
COPY conf/snippets /app/defaults/snippets
142+
# Note: JSON configuration (caddy.json) is generated dynamically by the backend
146143

147144
# Create required directories
148-
RUN mkdir -p /etc/caddy/sites /etc/caddy/backup /data /config
145+
RUN mkdir -p /etc/caddy/backup /data /config
149146

150147
# Expose ports
151148
# 80 - HTTP (redirect to HTTPS)

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ help:
1616
@echo " make status - Show container status"
1717
@echo " make clean - Remove containers, volumes, and images"
1818
@echo " make rebuild - Clean build and restart everything"
19-
@echo " make validate - Validate Caddyfile syntax"
19+
@echo " make validate - Validate Caddy JSON config"
2020
@echo " make deploy - Full deployment (env-check, build, up)"
2121
@echo ""
2222
@echo "Backend (Go):"
@@ -102,11 +102,11 @@ clean:
102102
# Rebuild everything from scratch
103103
rebuild: clean build up
104104

105-
# Validate Caddyfile syntax (requires running container)
105+
# Validate Caddy JSON config (requires running container)
106106
validate:
107-
@echo "Validating Caddyfile..."
108-
docker compose exec waygates caddy validate --config /etc/caddy/Caddyfile
109-
@echo "Caddyfile is valid"
107+
@echo "Validating Caddy JSON config..."
108+
docker compose exec waygates caddy validate --config /etc/caddy/caddy.json
109+
@echo "Caddy config is valid"
110110

111111
# Full deployment pipeline
112112
deploy: env-check build up

backend/cmd/server/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"syscall"
1212
"time"
1313

14+
// PostgreSQL driver
15+
_ "github.com/lib/pq"
1416
"go.uber.org/zap"
1517
"gorm.io/gorm"
1618

@@ -20,9 +22,6 @@ import (
2022
"github.com/aloks98/waygates/backend/internal/database"
2123
"github.com/aloks98/waygates/backend/internal/models"
2224
"github.com/aloks98/waygates/backend/internal/repository"
23-
24-
// PostgreSQL driver
25-
_ "github.com/lib/pq"
2625
)
2726

2827
func main() {

0 commit comments

Comments
 (0)