Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 58 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,53 @@ run:
timeout: 5m
modules-download-mode: readonly

issues:
max-issues-per-linter: 50
max-same-issues: 10

formatters:
enable:
- gci
- gofmt
- goimports

settings:
gci:
sections:
- standard
- default
- prefix(github.com/aloks98/waygates)

gofmt:
simplify: true

goimports:
local-prefixes:
- github.com/aloks98/waygates

linters:
enable:
# Core linters
- errcheck
- govet
- ineffassign
- staticcheck
- unused
- misspell
- unconvert
- gocritic

# Revive - comprehensive linter
- revive

# Additional useful linters
- bodyclose
- copyloopvar
- durationcheck
- errorlint
- gocritic
- gosec
- misspell
- nilerr
- prealloc
- unconvert

settings:
gocritic:
Expand All @@ -39,34 +60,60 @@ linters:
disabled-checks:
- hugeParam
- unnecessaryDefer

revive:
severity: warning
confidence: 0.8
rules:
# Default revive rules
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: error-naming
- name: errorf
- name: exported
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming

staticcheck:
checks:
- all
- -ST1000
- -ST1005
- -QF1003

misspell:
locale: US

issues:
max-issues-per-linter: 50
max-same-issues: 10
exclusions:
presets:
- std-error-handling
- common-false-positives
rules:
- text: 'should have a package comment'
linters: [ revive ]
- text: 'exported \S+ \S+ should have comment( \(or a comment on this block\))? or be unexported'
linters: [ revive ]
- text: 'avoid meaningless package names'
path: 'internal/utils/'
linters: [ revive ]
- path: '_test\.go'
linters:
- bodyclose
- errcheck
- gosec
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Waygates - Combined Backend + Caddy Container
# =============================================================================
# This Dockerfile creates a single container running both the Waygates backend
# and Caddy server. The backend manages Caddy configuration via Caddyfiles.
# and Caddy server. The backend manages Caddy configuration via JSON API.
#
# CUSTOMIZATION:
#
Expand Down Expand Up @@ -139,13 +139,10 @@ COPY --from=ui-builder /app/dist /app/ui
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

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

# Create required directories
RUN mkdir -p /etc/caddy/sites /etc/caddy/backup /data /config
RUN mkdir -p /etc/caddy/backup /data /config

# Expose ports
# 80 - HTTP (redirect to HTTPS)
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ help:
@echo " make status - Show container status"
@echo " make clean - Remove containers, volumes, and images"
@echo " make rebuild - Clean build and restart everything"
@echo " make validate - Validate Caddyfile syntax"
@echo " make validate - Validate Caddy JSON config"
@echo " make deploy - Full deployment (env-check, build, up)"
@echo ""
@echo "Backend (Go):"
Expand Down Expand Up @@ -102,11 +102,11 @@ clean:
# Rebuild everything from scratch
rebuild: clean build up

# Validate Caddyfile syntax (requires running container)
# Validate Caddy JSON config (requires running container)
validate:
@echo "Validating Caddyfile..."
docker compose exec waygates caddy validate --config /etc/caddy/Caddyfile
@echo "✓ Caddyfile is valid"
@echo "Validating Caddy JSON config..."
docker compose exec waygates caddy validate --config /etc/caddy/caddy.json
@echo "✓ Caddy config is valid"

# Full deployment pipeline
deploy: env-check build up
Expand Down
5 changes: 2 additions & 3 deletions backend/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"syscall"
"time"

// PostgreSQL driver
_ "github.com/lib/pq"
"go.uber.org/zap"
"gorm.io/gorm"

Expand All @@ -20,9 +22,6 @@ import (
"github.com/aloks98/waygates/backend/internal/database"
"github.com/aloks98/waygates/backend/internal/models"
"github.com/aloks98/waygates/backend/internal/repository"

// PostgreSQL driver
_ "github.com/lib/pq"
)

func main() {
Expand Down
Loading