diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9295ed9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.DS_Store +node_modules +dist +.git +.gitignore +*.md diff --git a/.env.example b/.env.example index 387cd4b..1fb25d0 100644 --- a/.env.example +++ b/.env.example @@ -17,9 +17,9 @@ HEADER_INJECT=HEADER_INJECT NO_FOLLOW=false NO_INDEX=false -SENTRY_AUTH_TOKEN=SENTRY_AUTH_TOKEN -SENTRY_DSN=SENTRY_DSN -SENTRY_PROJECT=SENTRY_PROJECT +SENTRY_AUTH_TOKEN= +SENTRY_DSN= +SENTRY_PROJECT= -HOST=telegram.dog +TELEGRAM_HOST=telegram.dog STATIC_PROXY="" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..11c0a9d --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/astro.config.mjs b/astro.config.mjs index 8baea61..f2bbbad 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -48,6 +48,7 @@ export default defineConfig({ ], vite: { ssr: { + noExternal: process.env.DOCKER ? !!process.env.DOCKER : undefined, external: [ ...adapterProvider === 'cloudflare_pages' ? [ diff --git a/package.json b/package.json index a8cbfdb..83f7d6c 100644 --- a/package.json +++ b/package.json @@ -12,13 +12,11 @@ "astro": "astro", "lint": "eslint .", "lint:fix": "eslint . --fix", - "postinstall": "simple-git-hooks" + "postinstall": "test -d .git && simple-git-hooks || true" }, "dependencies": { "@astrojs/rss": "^4.0.7", "@sentry/astro": "^8.26.0", - "astro": "^4.14.5", - "astro-seo": "^0.8.4", "cheerio": "1.0.0-rc.12", "dayjs": "^1.11.13", "flourite": "^1.3.0", @@ -35,7 +33,9 @@ "@astrojs/node": "^8.3.3", "@astrojs/vercel": "^7.8.0", "@types/prismjs": "^1.26.4", + "astro": "^4.14.5", "astro-eslint-parser": "^1.0.2", + "astro-seo": "^0.8.4", "autoprefixer": "^10.4.20", "cssnano": "^7.0.5", "eslint": "9.5.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4eb614a..74ca906 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,12 +14,6 @@ importers: '@sentry/astro': 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)) - 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: specifier: 1.0.0-rc.12 version: 1.0.0-rc.12 @@ -63,9 +57,15 @@ importers: '@types/prismjs': specifier: ^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: specifier: ^1.0.2 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: specifier: ^10.4.20 version: 10.4.20(postcss@8.4.41) @@ -3251,7 +3251,7 @@ packages: hasBin: true mime@3.0.0: - resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==} + resolution: {integrity: sha1-s3RVDco6DBhEOwyVCmpY8ZMc96c=} engines: {node: '>=10.0.0'} hasBin: true diff --git a/src/lib/telegram/index.js b/src/lib/telegram/index.js index b1271ed..7904617 100644 --- a/src/lib/telegram/index.js +++ b/src/lib/telegram/index.js @@ -183,7 +183,7 @@ export async function getChannelInfo(Astro, { before = '', after = '', q = '', t } // 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 staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'