mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-13 15:09:12 +00:00
feat: add Docker support and enhance environment configuration
- Introduce .dockerignore for Docker build optimization - Add Dockerfile for containerization setup - Update .env.example to clear Sentry variables and rename HOST to TELEGRAM_HOST - Modify astro.config.mjs to conditionally exclude SSR dependencies in Docker builds - Adjust postinstall script to safely handle missing .git directory - Refactor telegram host retrieval for clarity and consistency
This commit is contained in:
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
*.md
|
||||||
@@ -17,9 +17,9 @@ HEADER_INJECT=HEADER_INJECT
|
|||||||
NO_FOLLOW=false
|
NO_FOLLOW=false
|
||||||
NO_INDEX=false
|
NO_INDEX=false
|
||||||
|
|
||||||
SENTRY_AUTH_TOKEN=SENTRY_AUTH_TOKEN
|
SENTRY_AUTH_TOKEN=
|
||||||
SENTRY_DSN=SENTRY_DSN
|
SENTRY_DSN=
|
||||||
SENTRY_PROJECT=SENTRY_PROJECT
|
SENTRY_PROJECT=
|
||||||
|
|
||||||
HOST=telegram.dog
|
TELEGRAM_HOST=telegram.dog
|
||||||
STATIC_PROXY=""
|
STATIC_PROXY=""
|
||||||
|
|||||||
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
FROM node:lts-alpine AS base
|
||||||
|
|
||||||
|
ENV PNPM_HOME="/pnpm"
|
||||||
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
|
RUN corepack enable
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
# FROM base AS prod-deps
|
||||||
|
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
|
||||||
|
|
||||||
|
FROM base AS build-deps
|
||||||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
FROM build-deps AS build
|
||||||
|
COPY . .
|
||||||
|
RUN export $(cat .env.example) && export DOCKER=true && pnpm run build
|
||||||
|
|
||||||
|
FROM base AS runtime
|
||||||
|
# COPY --from=prod-deps /app/node_modules ./node_modules
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=4321
|
||||||
|
EXPOSE 4321
|
||||||
|
CMD node ./dist/server/entry.mjs
|
||||||
@@ -48,6 +48,7 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
vite: {
|
vite: {
|
||||||
ssr: {
|
ssr: {
|
||||||
|
noExternal: process.env.DOCKER ? !!process.env.DOCKER : undefined,
|
||||||
external: [
|
external: [
|
||||||
...adapterProvider === 'cloudflare_pages'
|
...adapterProvider === 'cloudflare_pages'
|
||||||
? [
|
? [
|
||||||
|
|||||||
@@ -12,13 +12,11 @@
|
|||||||
"astro": "astro",
|
"astro": "astro",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"postinstall": "simple-git-hooks"
|
"postinstall": "test -d .git && simple-git-hooks || true"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/rss": "^4.0.7",
|
"@astrojs/rss": "^4.0.7",
|
||||||
"@sentry/astro": "^8.26.0",
|
"@sentry/astro": "^8.26.0",
|
||||||
"astro": "^4.14.5",
|
|
||||||
"astro-seo": "^0.8.4",
|
|
||||||
"cheerio": "1.0.0-rc.12",
|
"cheerio": "1.0.0-rc.12",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"flourite": "^1.3.0",
|
"flourite": "^1.3.0",
|
||||||
@@ -35,7 +33,9 @@
|
|||||||
"@astrojs/node": "^8.3.3",
|
"@astrojs/node": "^8.3.3",
|
||||||
"@astrojs/vercel": "^7.8.0",
|
"@astrojs/vercel": "^7.8.0",
|
||||||
"@types/prismjs": "^1.26.4",
|
"@types/prismjs": "^1.26.4",
|
||||||
|
"astro": "^4.14.5",
|
||||||
"astro-eslint-parser": "^1.0.2",
|
"astro-eslint-parser": "^1.0.2",
|
||||||
|
"astro-seo": "^0.8.4",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"cssnano": "^7.0.5",
|
"cssnano": "^7.0.5",
|
||||||
"eslint": "9.5.0",
|
"eslint": "9.5.0",
|
||||||
|
|||||||
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@@ -14,12 +14,6 @@ importers:
|
|||||||
'@sentry/astro':
|
'@sentry/astro':
|
||||||
specifier: ^8.26.0
|
specifier: ^8.26.0
|
||||||
version: 8.26.0(astro@4.14.5(@types/node@22.0.0)(rollup@4.21.0)(typescript@5.5.4))
|
version: 8.26.0(astro@4.14.5(@types/node@22.0.0)(rollup@4.21.0)(typescript@5.5.4))
|
||||||
astro:
|
|
||||||
specifier: ^4.14.5
|
|
||||||
version: 4.14.5(@types/node@22.0.0)(rollup@4.21.0)(typescript@5.5.4)
|
|
||||||
astro-seo:
|
|
||||||
specifier: ^0.8.4
|
|
||||||
version: 0.8.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.5.4)
|
|
||||||
cheerio:
|
cheerio:
|
||||||
specifier: 1.0.0-rc.12
|
specifier: 1.0.0-rc.12
|
||||||
version: 1.0.0-rc.12
|
version: 1.0.0-rc.12
|
||||||
@@ -63,9 +57,15 @@ importers:
|
|||||||
'@types/prismjs':
|
'@types/prismjs':
|
||||||
specifier: ^1.26.4
|
specifier: ^1.26.4
|
||||||
version: 1.26.4
|
version: 1.26.4
|
||||||
|
astro:
|
||||||
|
specifier: ^4.14.5
|
||||||
|
version: 4.14.5(@types/node@22.0.0)(rollup@4.21.0)(typescript@5.5.4)
|
||||||
astro-eslint-parser:
|
astro-eslint-parser:
|
||||||
specifier: ^1.0.2
|
specifier: ^1.0.2
|
||||||
version: 1.0.2(typescript@5.5.4)
|
version: 1.0.2(typescript@5.5.4)
|
||||||
|
astro-seo:
|
||||||
|
specifier: ^0.8.4
|
||||||
|
version: 0.8.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.5.4)
|
||||||
autoprefixer:
|
autoprefixer:
|
||||||
specifier: ^10.4.20
|
specifier: ^10.4.20
|
||||||
version: 10.4.20(postcss@8.4.41)
|
version: 10.4.20(postcss@8.4.41)
|
||||||
@@ -3251,7 +3251,7 @@ packages:
|
|||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
mime@3.0.0:
|
mime@3.0.0:
|
||||||
resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==}
|
resolution: {integrity: sha1-s3RVDco6DBhEOwyVCmpY8ZMc96c=}
|
||||||
engines: {node: '>=10.0.0'}
|
engines: {node: '>=10.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ export async function getChannelInfo(Astro, { before = '', after = '', q = '', t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Where t.me can also be telegram.me, telegram.dog
|
// Where t.me can also be telegram.me, telegram.dog
|
||||||
const host = getEnv(import.meta.env, Astro, 'HOST') ?? 't.me'
|
const host = getEnv(import.meta.env, Astro, 'TELEGRAM_HOST') ?? 't.me'
|
||||||
const channel = getEnv(import.meta.env, Astro, 'CHANNEL')
|
const channel = getEnv(import.meta.env, Astro, 'CHANNEL')
|
||||||
const staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'
|
const staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user