Deploy client-cms to caddy container
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Exchange handles the authorization code swap process.
|
// Exchange handles the authorization code swap process.
|
||||||
|
//
|
||||||
// @Summary Exchange Auth Code
|
// @Summary Exchange Auth Code
|
||||||
// @Description Exchanges client credentials and user session for a specific redirect authorization code.
|
// @Description Exchanges client credentials and user session for a specific redirect authorization code.
|
||||||
// @Tags Authentication
|
// @Tags Authentication
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Magic handles the "Magic Link" authentication request.
|
// Magic handles the "Magic Link" authentication request.
|
||||||
|
//
|
||||||
// @Summary Request Magic Link
|
// @Summary Request Magic Link
|
||||||
// @Description Verifies Turnstile token and sends an authentication link via email. Returns the URI directly if debug mode is enabled.
|
// @Description Verifies Turnstile token and sends an authentication link via email. Returns the URI directly if debug mode is enabled.
|
||||||
// @Tags Authentication
|
// @Tags Authentication
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Redirect handles the post-verification callback and redirects the user to the target application.
|
// Redirect handles the post-verification callback and redirects the user to the target application.
|
||||||
|
//
|
||||||
// @Summary Handle Auth Callback and Redirect
|
// @Summary Handle Auth Callback and Redirect
|
||||||
// @Description Verifies the temporary email code, ensures the user exists (or creates one), validates the client's redirect URI, and finally performs a 302 redirect with a new authorization code.
|
// @Description Verifies the temporary email code, ensures the user exists (or creates one), validates the client's redirect URI, and finally performs a 302 redirect with a new authorization code.
|
||||||
// @Tags Authentication
|
// @Tags Authentication
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Refresh handles the token rotation process.
|
// Refresh handles the token rotation process.
|
||||||
|
//
|
||||||
// @Summary Refresh Access Token
|
// @Summary Refresh Access Token
|
||||||
// @Description Accepts a valid refresh token to issue a new access token and a rotated refresh token.
|
// @Description Accepts a valid refresh token to issue a new access token and a rotated refresh token.
|
||||||
// @Tags Authentication
|
// @Tags Authentication
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Token exchanges an authorization code for access and refresh tokens.
|
// Token exchanges an authorization code for access and refresh tokens.
|
||||||
|
//
|
||||||
// @Summary Exchange Code for Token
|
// @Summary Exchange Code for Token
|
||||||
// @Description Verifies the provided authorization code and issues a pair of JWT tokens (Access and Refresh).
|
// @Description Verifies the provided authorization code and issues a pair of JWT tokens (Access and Refresh).
|
||||||
// @Tags Authentication
|
// @Tags Authentication
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Checkin generates a check-in code for a specific event.
|
// Checkin generates a check-in code for a specific event.
|
||||||
|
//
|
||||||
// @Summary Generate Check-in Code
|
// @Summary Generate Check-in Code
|
||||||
// @Description Creates a temporary check-in code for the authenticated user and event.
|
// @Description Creates a temporary check-in code for the authenticated user and event.
|
||||||
// @Tags Event
|
// @Tags Event
|
||||||
@@ -49,6 +50,7 @@ func (self *EventHandler) Checkin(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CheckinSubmit validates a check-in code to complete attendance.
|
// CheckinSubmit validates a check-in code to complete attendance.
|
||||||
|
//
|
||||||
// @Summary Submit Check-in Code
|
// @Summary Submit Check-in Code
|
||||||
// @Description Submits the generated code to mark the user as attended.
|
// @Description Submits the generated code to mark the user as attended.
|
||||||
// @Tags Event
|
// @Tags Event
|
||||||
@@ -82,6 +84,7 @@ func (self *EventHandler) CheckinSubmit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CheckinQuery retrieves the check-in status of a user for an event.
|
// CheckinQuery retrieves the check-in status of a user for an event.
|
||||||
|
//
|
||||||
// @Summary Query Check-in Status
|
// @Summary Query Check-in Status
|
||||||
// @Description Returns the timestamp of when the user checked in, or null if not yet checked in.
|
// @Description Returns the timestamp of when the user checked in, or null if not yet checked in.
|
||||||
// @Tags Event
|
// @Tags Event
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Info retrieves basic information about a specific event.
|
// Info retrieves basic information about a specific event.
|
||||||
|
//
|
||||||
// @Summary Get Event Information
|
// @Summary Get Event Information
|
||||||
// @Description Fetches the name, start time, and end time of an event using its UUID.
|
// @Description Fetches the name, start time, and end time of an event using its UUID.
|
||||||
// @Tags Event
|
// @Tags Event
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Full retrieves the complete list of users directly from the database table.
|
// Full retrieves the complete list of users directly from the database table.
|
||||||
|
//
|
||||||
// @Summary Get Full User Table
|
// @Summary Get Full User Table
|
||||||
// @Description Fetches all user records without pagination. This is typically used for administrative overview or data export.
|
// @Description Fetches all user records without pagination. This is typically used for administrative overview or data export.
|
||||||
// @Tags User
|
// @Tags User
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Info retrieves the profile information of the currently authenticated user.
|
// Info retrieves the profile information of the currently authenticated user.
|
||||||
|
//
|
||||||
// @Summary Get My User Information
|
// @Summary Get My User Information
|
||||||
// @Description Fetches the complete profile data for the user associated with the provided session/token.
|
// @Description Fetches the complete profile data for the user associated with the provided session/token.
|
||||||
// @Tags User
|
// @Tags User
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// List retrieves a paginated list of users from the search engine.
|
// List retrieves a paginated list of users from the search engine.
|
||||||
|
//
|
||||||
// @Summary List Users
|
// @Summary List Users
|
||||||
// @Description Fetches a list of users with support for pagination via limit and offset. Data is sourced from the search engine for high performance.
|
// @Description Fetches a list of users with support for pagination via limit and offset. Data is sourced from the search engine for high performance.
|
||||||
// @Tags User
|
// @Tags User
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Update modifies the profile information for the currently authenticated user.
|
// Update modifies the profile information for the currently authenticated user.
|
||||||
|
//
|
||||||
// @Summary Update User Information
|
// @Summary Update User Information
|
||||||
// @Description Updates specific profile fields such as username, nickname, subtitle, avatar (URL), and bio (Base64).
|
// @Description Updates specific profile fields such as username, nickname, subtitle, avatar (URL), and bio (Base64).
|
||||||
// @Description Validation: Username (5-255 chars), Nickname (max 24 chars), Subtitle (max 32 chars).
|
// @Description Validation: Username (5-255 chars), Nickname (max 24 chars), Subtitle (max 32 chars).
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ COPY . .
|
|||||||
RUN cd client/cms && pnpm install
|
RUN cd client/cms && pnpm install
|
||||||
RUN cd client/cms && pnpm run build --outDir /app/.outputs/client/cms/dist
|
RUN cd client/cms && pnpm run build --outDir /app/.outputs/client/cms/dist
|
||||||
|
|
||||||
FROM docker.io/busybox:1.37
|
FROM docker.io/caddy:2-alpine
|
||||||
WORKDIR /app
|
COPY ./deploy/client-cms.Caddyfile /etc/caddy/Caddyfile
|
||||||
COPY --from=client-cms-build /app/.outputs/client/cms/dist .
|
COPY --from=client-cms-build /app/.outputs/client/cms/dist /srv
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENTRYPOINT ["httpd", "-f", "-p", "3000", "-h", "/app", "-v"]
|
ENTRYPOINT ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
test.nix.org.cn {
|
test.nix.org.cn {
|
||||||
handle_path /* {
|
handle /api/* {
|
||||||
reverse_proxy client-cms:3000
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_path /api/* {
|
|
||||||
reverse_proxy backend:8000
|
reverse_proxy backend:8000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle {
|
||||||
|
reverse_proxy client-cms:3000
|
||||||
|
}
|
||||||
}
|
}
|
||||||
6
deploy/client-cms.Caddyfile
Normal file
6
deploy/client-cms.Caddyfile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
:3000 {
|
||||||
|
root * /srv
|
||||||
|
encode zstd gzip
|
||||||
|
try_files {path} /index.html
|
||||||
|
file_server
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ services:
|
|||||||
POSTGRES_DB: postgres
|
POSTGRES_DB: postgres
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/postgres:/var/lib/postgresql/data
|
- ./data/postgres:/var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
|
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
2
go.mod
2
go.mod
@@ -19,6 +19,7 @@ require (
|
|||||||
github.com/spf13/viper v1.21.0
|
github.com/spf13/viper v1.21.0
|
||||||
github.com/swaggo/files v1.0.1
|
github.com/swaggo/files v1.0.1
|
||||||
github.com/swaggo/gin-swagger v1.6.1
|
github.com/swaggo/gin-swagger v1.6.1
|
||||||
|
github.com/swaggo/swag v1.16.6
|
||||||
go.opentelemetry.io/contrib/bridges/otelslog v0.14.0
|
go.opentelemetry.io/contrib/bridges/otelslog v0.14.0
|
||||||
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.64.0
|
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.64.0
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
|
||||||
@@ -112,7 +113,6 @@ require (
|
|||||||
github.com/spf13/cast v1.10.0 // indirect
|
github.com/spf13/cast v1.10.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.10 // indirect
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
github.com/subosito/gotenv v1.6.0 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
github.com/swaggo/swag v1.16.6 // indirect
|
|
||||||
github.com/tjfoc/gmsm v1.4.1 // indirect
|
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||||
|
|||||||
Reference in New Issue
Block a user