feat(docker): Add Dockerfile and compose file

This commit is contained in:
Björn Benouarets
2025-11-29 03:09:40 +01:00
parent 08055398c4
commit 3c08a2cb25
13 changed files with 381 additions and 9 deletions

24
app/models/domain.go Normal file
View File

@@ -0,0 +1,24 @@
package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type Domain struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
Name string `gorm:"not null;unique" json:"name"`
Verified bool `gorm:"not null;default:false" json:"verified"`
VerificationToken string `gorm:"not null;unique" json:"verification_token"`
CreatedAt time.Time `gorm:"not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Records []Record `gorm:"foreignKey:DomainID" json:"-"`
}
func (Domain) TableName() string {
return "domains"
}

View File

@@ -9,10 +9,15 @@ import (
type Endpoint struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
URL string `gorm:"not null" json:"url"`
Path string `gorm:"not null;default:/" json:"path"`
RecordID uuid.UUID `gorm:"not null;uniqueIndex:idx_endpoint_record_id" json:"record_id"`
CreatedAt time.Time `gorm:"not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Record Record `gorm:"foreignKey:RecordID" json:"-"`
EndpointGroups []EndpointGroup `gorm:"foreignKey:EndpointID" json:"-"`
}
func (Endpoint) TableName() string {

View File

@@ -0,0 +1,24 @@
package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type EndpointGroup struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
GroupID uuid.UUID `gorm:"not null;uniqueIndex:idx_endpoint_group_group_id_endpoint_id" json:"group_id"`
EndpointID uuid.UUID `gorm:"not null;uniqueIndex:idx_endpoint_group_group_id_endpoint_id" json:"endpoint_id"`
CreatedAt time.Time `gorm:"not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Group Group `gorm:"foreignKey:GroupID" json:"-"`
Endpoint Endpoint `gorm:"foreignKey:EndpointID" json:"-"`
}
func (EndpointGroup) TableName() string {
return "endpoint_groups"
}

23
app/models/group.go Normal file
View File

@@ -0,0 +1,23 @@
package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type Group struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
Name string `gorm:"not null;unique" json:"name"`
Description *string `json:"description"`
CreatedAt time.Time `gorm:"not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
EndpointGroups []EndpointGroup `gorm:"foreignKey:GroupID" json:"-"`
}
func (Group) TableName() string {
return "groups"
}

25
app/models/record.go Normal file
View File

@@ -0,0 +1,25 @@
package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type Record struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
Record string `gorm:"not null;uniqueIndex:idx_record_domain_id" json:"record"`
DomainID uuid.UUID `gorm:"not null;uniqueIndex:idx_record_domain_id" json:"domain_id"`
CreatedAt time.Time `gorm:"not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"not null;default:now()" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Domain Domain `gorm:"foreignKey:DomainID" json:"-"`
Endpoints []Endpoint `gorm:"foreignKey:RecordID" json:"-"`
}
func (Record) TableName() string {
return "records"
}