diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1ae2602 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# syntax=docker/dockerfile:1 +FROM node:22-bookworm-slim AS build +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm ci + +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine +COPY docker/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html +EXPOSE 80 +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ + CMD wget -q -O /dev/null http://127.0.0.1/ || exit 1 diff --git a/astro.config.mjs b/astro.config.mjs index da0a715..333fcc6 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -9,7 +9,7 @@ import { remarkObsidian } from './src/plugins/remark-obsidian.mjs'; // https://astro.build/config // Astro 7 默认 Sätteri 不跑 remark 插件;笔记博客需要 [[wikilink]],改用 unified export default defineConfig({ - site: 'https://example.com', + site: 'https://notebook.any.me.uk', integrations: [mdx(), sitemap()], markdown: { processor: unified({ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..035c8db --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +name: notebook + +services: + notebook: + build: + context: . + dockerfile: Dockerfile + image: harbor.any.me.uk/library/notebook:latest + container_name: notebook + restart: unless-stopped + ports: + - "127.0.0.1:3030:80" diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..2f184b3 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,21 @@ +server { + listen 80; + listen [::]:80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Astro static: pretty URLs with trailing directories + location / { + try_files $uri $uri/ $uri.html /index.html; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { + expires 7d; + add_header Cache-Control "public, max-age=604800"; + try_files $uri =404; + } + + gzip on; + gzip_types text/css application/javascript application/json image/svg+xml; +} diff --git a/src/consts.ts b/src/consts.ts index 5bfa334..0b4b878 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -4,7 +4,7 @@ export const SITE_DESCRIPTION = '用 Obsidian 写作,用 Astro 发布的个人 export const SITE_AUTHOR = '你的名字'; /** 部署域名,构建 RSS / sitemap 会用到(不要带 https://) */ -export const SITE_URL = 'https://example.com'; +export const SITE_URL = 'https://notebook.any.me.uk'; /** * Obsidian 库路径(给 scripts/sync-vault.mjs 用)