This commit is contained in:
longdayi 2025-05-26 21:45:30 +08:00
parent 413e46ce14
commit 251260aace
10 changed files with 156 additions and 6 deletions

View File

@ -13,6 +13,7 @@
"hono": "^4.7.10",
"ioredis": "5.4.1",
"minio": "7.1.3",
"nanoid": "^5.1.5",
"node-cron": "^4.0.7",
"oidc-provider": "^9.1.1",
"zod": "^3.25.23"

View File

@ -41,10 +41,9 @@ app.use(
app.get('/', (c) => {
return c.text('Hello Hono!')
})
app.all('/oidc/*', async (c) => {
// 让 oidc-provider 处理请求
return await oidc.callback(c.req.raw, c.res.raw);
});
app.use('/oidc/*', async (c, next) => {
// @ts-ignore
await oidc.callback(c.req.raw, c.res.raw)
return c.finalize()
})
export default app

View File

@ -0,0 +1,10 @@
# 导入独立配置文件
x-common-variables: &common-variables
env_file: .env
include:
- dockers/database-postgres.yml
- dockers/cache-redis.yml
- dockers/storage-minio.yml
- dockers/search-elasticsearch.yml
- dockers/networks.yml

10
docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
# 导入独立配置文件
x-common-variables: &common-variables
env_file: .env
include:
- dockers/database-postgres.yml
- dockers/cache-redis.yml
- dockers/storage-minio.yml
- dockers/search-elasticsearch.yml
- dockers/networks.yml

27
dockers/cache-redis.yml Normal file
View File

@ -0,0 +1,27 @@
services:
redis:
image: redis:${REDIS_VERSION:-7.2.4}
container_name: redis
restart: always
ports:
- "6379:6379"
networks:
- nice-net
volumes:
- type: volume
source: cache_data
target: /data
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-nice_redis_password}
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 3s
retries: 3
volumes:
cache_data:
driver: local
driver_opts:
type: none
device: ${PWD}/volumes/redis
o: bind

View File

@ -0,0 +1,34 @@
services:
db:
image: postgres:${POSTGRES_VERSION:-16}
container_name: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_DB=${POSTGRES_DB:-nice_db}
- POSTGRES_USER=${POSTGRES_USER:-nice_user}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nice_password}
volumes:
- type: volume
source: postgres_data
target: /var/lib/postgresql/data
healthcheck:
test:
[
"CMD-SHELL",
"sh -c 'pg_isready -U ${POSTGRES_USER:-nice_user} -d ${POSTGRES_DB:-nice_db}'",
]
interval: 10s
timeout: 3s
retries: 3
restart: always
networks:
- nice-net
volumes:
postgres_data:
driver: local
driver_opts:
type: none
device: ${PWD}/volumes/postgres
o: bind

3
dockers/networks.yml Normal file
View File

@ -0,0 +1,3 @@
networks:
nice-net:
driver: bridge

View File

@ -0,0 +1,32 @@
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION:-8.12.2}
container_name: elasticsearch
restart: always
ports:
- "9200:9200"
- "9300:9300"
networks:
- nice-net
environment:
- discovery.type=single-node
- xpack.security.enabled=true
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-nice_elastic_password}
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- type: volume
source: elasticsearch_data
target: /usr/share/elasticsearch/data
healthcheck:
test: curl -s http://localhost:9200/_cluster/health | grep -v '"status":"red"'
interval: 10s
timeout: 5s
retries: 3
volumes:
elasticsearch_data:
driver: local
driver_opts:
type: none
device: ${PWD}/volumes/elasticsearch
o: bind

31
dockers/storage-minio.yml Normal file
View File

@ -0,0 +1,31 @@
services:
minio:
image: minio/minio:${MINIO_VERSION:-RELEASE.2024-04-22T22-12-26Z}
container_name: minio
restart: always
ports:
- "9000:9000"
- "9001:9001"
networks:
- nice-net
environment:
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-nice_minio_access}
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-nice_minio_secret}
volumes:
- type: volume
source: storage_data
target: /data
command: server /data --console-address ":9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
volumes:
storage_data:
driver: local
driver_opts:
type: none
device: ${PWD}/volumes/minio
o: bind

View File

@ -56,6 +56,9 @@ importers:
minio:
specifier: 7.1.3
version: 7.1.3
nanoid:
specifier: ^5.1.5
version: 5.1.5
node-cron:
specifier: ^4.0.7
version: 4.0.7