diff --git a/Dockerfile b/Dockerfile index acc0ba1..7c2b83c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN set -ex \ && update-ca-certificates \ && go mod download \ && go mod verify \ - && GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o app . \ + && make build \ && chmod +x /build/app FROM alpine diff --git a/Makefile b/Makefile index f26eec3..56aeeed 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ IMAGE := eikendev/pushbits .PHONY: build build: - go build -ldflags="-w -s" -o app . + go build -ldflags="-w -s" -o app ./cmd/pushbits .PHONY: test test: diff --git a/app.go b/cmd/pushbits/main.go similarity index 75% rename from app.go rename to cmd/pushbits/main.go index 98b1ca8..84a5a5d 100644 --- a/app.go +++ b/cmd/pushbits/main.go @@ -6,12 +6,12 @@ import ( "os/signal" "syscall" - "github.com/pushbits/server/authentication/credentials" - "github.com/pushbits/server/configuration" - "github.com/pushbits/server/database" - "github.com/pushbits/server/dispatcher" - "github.com/pushbits/server/router" - "github.com/pushbits/server/runner" + "github.com/pushbits/server/internal/authentication/credentials" + "github.com/pushbits/server/internal/configuration" + "github.com/pushbits/server/internal/database" + "github.com/pushbits/server/internal/dispatcher" + "github.com/pushbits/server/internal/router" + "github.com/pushbits/server/internal/runner" ) func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) { diff --git a/api/application.go b/internal/api/application.go similarity index 97% rename from api/application.go rename to internal/api/application.go index 4d291fc..2346f8f 100644 --- a/api/application.go +++ b/internal/api/application.go @@ -5,8 +5,8 @@ import ( "log" "net/http" - "github.com/pushbits/server/authentication" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/authentication" + "github.com/pushbits/server/internal/model" "github.com/gin-gonic/gin" ) diff --git a/api/context.go b/internal/api/context.go similarity index 95% rename from api/context.go rename to internal/api/context.go index 0b95b44..c408515 100644 --- a/api/context.go +++ b/internal/api/context.go @@ -4,7 +4,7 @@ import ( "errors" "net/http" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/model" "github.com/gin-gonic/gin" ) diff --git a/api/health.go b/internal/api/health.go similarity index 100% rename from api/health.go rename to internal/api/health.go diff --git a/api/interfaces.go b/internal/api/interfaces.go similarity index 96% rename from api/interfaces.go rename to internal/api/interfaces.go index 090390c..d3b98ca 100644 --- a/api/interfaces.go +++ b/internal/api/interfaces.go @@ -1,7 +1,7 @@ package api import ( - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/model" ) // The Database interface for encapsulating database access. diff --git a/api/middleware.go b/internal/api/middleware.go similarity index 100% rename from api/middleware.go rename to internal/api/middleware.go diff --git a/api/notification.go b/internal/api/notification.go similarity index 92% rename from api/notification.go rename to internal/api/notification.go index 86817f6..553bf1c 100644 --- a/api/notification.go +++ b/internal/api/notification.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/pushbits/server/authentication" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/authentication" + "github.com/pushbits/server/internal/model" "github.com/gin-gonic/gin" ) diff --git a/api/user.go b/internal/api/user.go similarity index 98% rename from api/user.go rename to internal/api/user.go index 4b1852b..f33bd94 100644 --- a/api/user.go +++ b/internal/api/user.go @@ -5,8 +5,8 @@ import ( "log" "net/http" - "github.com/pushbits/server/authentication" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/authentication" + "github.com/pushbits/server/internal/model" "github.com/gin-gonic/gin" ) diff --git a/api/util.go b/internal/api/util.go similarity index 89% rename from api/util.go rename to internal/api/util.go index dc84df3..d40d833 100644 --- a/api/util.go +++ b/internal/api/util.go @@ -4,7 +4,7 @@ import ( "errors" "net/http" - "github.com/pushbits/server/authentication" + "github.com/pushbits/server/internal/authentication" "github.com/gin-gonic/gin" ) diff --git a/assert/assert.go b/internal/assert/assert.go similarity index 100% rename from assert/assert.go rename to internal/assert/assert.go diff --git a/authentication/authentication.go b/internal/authentication/authentication.go similarity index 96% rename from authentication/authentication.go rename to internal/authentication/authentication.go index d1f5a8d..8cd0635 100644 --- a/authentication/authentication.go +++ b/internal/authentication/authentication.go @@ -4,8 +4,8 @@ import ( "errors" "net/http" - "github.com/pushbits/server/authentication/credentials" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/authentication/credentials" + "github.com/pushbits/server/internal/model" "github.com/gin-gonic/gin" ) diff --git a/authentication/context.go b/internal/authentication/context.go similarity index 94% rename from authentication/context.go rename to internal/authentication/context.go index 5a7947a..5326646 100644 --- a/authentication/context.go +++ b/internal/authentication/context.go @@ -4,7 +4,7 @@ import ( "errors" "net/http" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/model" "github.com/gin-gonic/gin" ) diff --git a/authentication/credentials/credentials.go b/internal/authentication/credentials/credentials.go similarity index 92% rename from authentication/credentials/credentials.go rename to internal/authentication/credentials/credentials.go index eda3e7c..1280f5b 100644 --- a/authentication/credentials/credentials.go +++ b/internal/authentication/credentials/credentials.go @@ -3,7 +3,7 @@ package credentials import ( "log" - "github.com/pushbits/server/configuration" + "github.com/pushbits/server/internal/configuration" "github.com/alexedwards/argon2id" ) diff --git a/authentication/credentials/hibp.go b/internal/authentication/credentials/hibp.go similarity index 100% rename from authentication/credentials/hibp.go rename to internal/authentication/credentials/hibp.go diff --git a/authentication/credentials/hibp_test.go b/internal/authentication/credentials/hibp_test.go similarity index 100% rename from authentication/credentials/hibp_test.go rename to internal/authentication/credentials/hibp_test.go diff --git a/authentication/credentials/password.go b/internal/authentication/credentials/password.go similarity index 100% rename from authentication/credentials/password.go rename to internal/authentication/credentials/password.go diff --git a/authentication/token.go b/internal/authentication/token.go similarity index 100% rename from authentication/token.go rename to internal/authentication/token.go diff --git a/configuration/configuration.go b/internal/configuration/configuration.go similarity index 100% rename from configuration/configuration.go rename to internal/configuration/configuration.go diff --git a/database/application.go b/internal/database/application.go similarity index 93% rename from database/application.go rename to internal/database/application.go index 76c0737..9a45d75 100644 --- a/database/application.go +++ b/internal/database/application.go @@ -3,8 +3,8 @@ package database import ( "errors" - "github.com/pushbits/server/assert" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/assert" + "github.com/pushbits/server/internal/model" "gorm.io/gorm" ) diff --git a/database/database.go b/internal/database/database.go similarity index 94% rename from database/database.go rename to internal/database/database.go index bc56d38..b4bc3d8 100644 --- a/database/database.go +++ b/internal/database/database.go @@ -8,8 +8,8 @@ import ( "path/filepath" "time" - "github.com/pushbits/server/authentication/credentials" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/authentication/credentials" + "github.com/pushbits/server/internal/model" "gorm.io/driver/mysql" "gorm.io/driver/sqlite" diff --git a/database/health.go b/internal/database/health.go similarity index 100% rename from database/health.go rename to internal/database/health.go diff --git a/database/user.go b/internal/database/user.go similarity index 95% rename from database/user.go rename to internal/database/user.go index 57fc674..3c2c136 100644 --- a/database/user.go +++ b/internal/database/user.go @@ -3,8 +3,8 @@ package database import ( "errors" - "github.com/pushbits/server/assert" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/assert" + "github.com/pushbits/server/internal/model" "gorm.io/gorm" ) diff --git a/dispatcher/application.go b/internal/dispatcher/application.go similarity index 96% rename from dispatcher/application.go rename to internal/dispatcher/application.go index 36911e3..c2887ab 100644 --- a/dispatcher/application.go +++ b/internal/dispatcher/application.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/model" "github.com/matrix-org/gomatrix" ) diff --git a/dispatcher/dispatcher.go b/internal/dispatcher/dispatcher.go similarity index 100% rename from dispatcher/dispatcher.go rename to internal/dispatcher/dispatcher.go diff --git a/dispatcher/notification.go b/internal/dispatcher/notification.go similarity index 89% rename from dispatcher/notification.go rename to internal/dispatcher/notification.go index 9ebfbd2..74a0302 100644 --- a/dispatcher/notification.go +++ b/internal/dispatcher/notification.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - "github.com/pushbits/server/model" + "github.com/pushbits/server/internal/model" ) // SendNotification sends a notification to the specified user. diff --git a/model/application.go b/internal/model/application.go similarity index 100% rename from model/application.go rename to internal/model/application.go diff --git a/model/notification.go b/internal/model/notification.go similarity index 100% rename from model/notification.go rename to internal/model/notification.go diff --git a/model/user.go b/internal/model/user.go similarity index 97% rename from model/user.go rename to internal/model/user.go index e984672..ddb77cf 100644 --- a/model/user.go +++ b/internal/model/user.go @@ -3,7 +3,7 @@ package model import ( "log" - "github.com/pushbits/server/authentication/credentials" + "github.com/pushbits/server/internal/authentication/credentials" ) // User holds information like the name, the secret, and the applications of a user. diff --git a/router/router.go b/internal/router/router.go similarity index 86% rename from router/router.go rename to internal/router/router.go index 2ca408d..587c256 100644 --- a/router/router.go +++ b/internal/router/router.go @@ -3,11 +3,11 @@ package router import ( "log" - "github.com/pushbits/server/api" - "github.com/pushbits/server/authentication" - "github.com/pushbits/server/authentication/credentials" - "github.com/pushbits/server/database" - "github.com/pushbits/server/dispatcher" + "github.com/pushbits/server/internal/api" + "github.com/pushbits/server/internal/authentication" + "github.com/pushbits/server/internal/authentication/credentials" + "github.com/pushbits/server/internal/database" + "github.com/pushbits/server/internal/dispatcher" "github.com/gin-contrib/location" "github.com/gin-gonic/gin" diff --git a/runner/runner.go b/internal/runner/runner.go similarity index 100% rename from runner/runner.go rename to internal/runner/runner.go