2 Commits
Author SHA1 Message Date
sittichok Ouamsiri 18bb686e3e feat: update deploy 2026-06-15 22:45:38 +07:00
sittichok Ouamsiri 9b550f4be2 feat: .env.example 2026-06-15 21:45:29 +07:00
5 changed files with 49 additions and 9 deletions
+34
View File
@@ -0,0 +1,34 @@
# ── Storage ──────────────────────────────────────────────────────────────────
STORE=postgres
DATABASE_URL=postgres://snip:snip@localhost:5432/snip?sslmode=disable
# ── Redis ─────────────────────────────────────────────────────────────────────
REDIS_ADDR=localhost:6379
REDIS_PASSWORD=
REDIS_DB=0
# Namespace prefix for all Redis keys — set this when sharing a Redis instance
# with other apps, e.g. REDIS_KEY_PREFIX=snip: → keys look like snip:code:abc
REDIS_KEY_PREFIX=
# ── App ───────────────────────────────────────────────────────────────────────
PUBLIC_URL=http://localhost:8080
SHORT_DOMAIN=localhost:8080
POST_LOGIN_REDIRECT=/dashboard
FRONTEND_DIST=./web
# ── Security ──────────────────────────────────────────────────────────────────
SESSION_SECRET=change-me-in-production
COOKIE_SECURE=false
# ── Google OAuth (optional) ───────────────────────────────────────────────────
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# ── Generic OIDC (optional) ───────────────────────────────────────────────────
OIDC_ISSUER=
OIDC_CLIENT_ID=
OIDC_CLIENT_SECRET=
# ── Misc ──────────────────────────────────────────────────────────────────────
# How often buffered click counts are flushed to Postgres (seconds)
CLICK_FLUSH_SECONDS=10
+7 -3
View File
@@ -12,7 +12,7 @@ permissions:
jobs:
trigger-internal-build:
uses: infras/workflow-templates/.gitea/workflows/docker-template.yml@1d6923bc938dabb10d5c8c98fadf8abeb6744be3
uses: infras/workflow-templates/.gitea/workflows/docker-template.yml@736cd715b4b9c80f20ec51ef8445cb630c8299f5
with:
image_name: 'snip'
image_tag: ${{ gitea.ref_name }}
@@ -22,9 +22,13 @@ jobs:
bump-compose:
needs: trigger-internal-build
uses: infras/workflow-templates/.gitea/workflows/bump-compose-version.yml@1d6923bc938dabb10d5c8c98fadf8abeb6744be3
uses: infras/workflow-templates/.gitea/workflows/bump-compose-version.yml@736cd715b4b9c80f20ec51ef8445cb630c8299f5
with:
app: snip
version: ${{ gitea.ref_name }}
update: |
snip-migrate:${{ gitea.ref_name }}
snip-api:${{ gitea.ref_name }}
snip-frontend:${{ gitea.ref_name }}
snip-redirect:${{ gitea.ref_name }}
secrets:
COMPOSE_TOKEN: ${{ secrets.COMPOSE_TOKEN }}
+2 -2
View File
@@ -17,13 +17,13 @@ type Cache struct {
prefix string
}
func New(ctx context.Context, addr, password string, db int) (*Cache, error) {
func New(ctx context.Context, addr, password string, db int, keyPrefix string) (*Cache, error) {
rdb := redis.NewClient(&redis.Options{Addr: addr, Password: password, DB: db})
if err := rdb.Ping(ctx).Err(); err != nil {
_ = rdb.Close()
return nil, err
}
return &Cache{rdb: rdb, prefix: "code:"}, nil
return &Cache{rdb: rdb, prefix: keyPrefix + "code:"}, nil
}
func (c *Cache) key(code string) string { return c.prefix + code }
+2
View File
@@ -15,6 +15,7 @@ type Config struct {
RedisAddr string
RedisPassword string
RedisDB int
RedisKeyPrefix string
// PublicURL is the externally reachable base (used to build OAuth callback
// URLs). PostLoginRedirect is where users land after a successful login.
@@ -76,6 +77,7 @@ func Load() Config {
RedisAddr: env("REDIS_ADDR", "localhost:6379"),
RedisPassword: env("REDIS_PASSWORD", ""),
RedisDB: envInt("REDIS_DB", 0),
RedisKeyPrefix: env("REDIS_KEY_PREFIX", ""),
PublicURL: env("PUBLIC_URL", "http://localhost:8080"),
PostLoginRedirect: env("POST_LOGIN_REDIRECT", "/dashboard"),
FrontendDist: env("FRONTEND_DIST", "./web"),
+1 -1
View File
@@ -56,7 +56,7 @@ func (c *Container) buildInfra(ctx context.Context) (*infra, error) {
if err != nil {
return nil, err
}
cache, err := rediscache.New(ctx, c.cfg.RedisAddr, c.cfg.RedisPassword, c.cfg.RedisDB)
cache, err := rediscache.New(ctx, c.cfg.RedisAddr, c.cfg.RedisPassword, c.cfg.RedisDB, c.cfg.RedisKeyPrefix)
if err != nil {
pool.Close()
return nil, err