컨텐츠로 건너뛰기

배포

girok-md는 GitHub Pages, Vercel, Netlify 또는 모든 정적 호스팅 플랫폼에 배포할 수 있습니다.

GitHub Pages (권장)

  1. 워크플로우 파일 생성

    .github/workflows/deploy.yml 생성:

    .github/workflows/deploy.yml
    name: Deploy to GitHub Pages
    on:
    push:
    branches: [main]
    workflow_dispatch:
    permissions:
    contents: read
    pages: write
    id-token: write
    concurrency:
    group: pages
    cancel-in-progress: false
    jobs:
    build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
    uses: actions/checkout@v4
    - name: Setup Node
    uses: actions/setup-node@v4
    with:
    node-version: 20
    cache: npm
    - name: Install dependencies
    run: npm ci
    - name: Build
    run: npm run build
    - name: Upload artifact
    uses: actions/upload-pages-artifact@v3
    with:
    path: ./dist
    deploy:
    needs: build
    runs-on: ubuntu-latest
    environment:
    name: github-pages
    url: ${{ steps.deployment.outputs.page_url }}
    steps:
    - name: Deploy to GitHub Pages
    id: deployment
    uses: actions/deploy-pages@v4
  2. GitHub Pages 설정

    1. 저장소의 SettingsPages로 이동
    2. Source에서 GitHub Actions 선택
    3. 설정 저장
  3. 푸시하여 배포

    Terminal window
    git add .
    git commit -m "Add GitHub Pages deployment"
    git push

    사이트는 https://username.github.io/repository-name에서 사용 가능합니다

커스텀 도메인

커스텀 도메인을 사용하려면:

  1. public/CNAME 파일 생성:

    public/CNAME
    your-domain.com
  2. setting.toml 업데이트:

    setting.toml
    site_url = "https://your-domain.com"
  3. 도메인 제공업체에서 DNS 설정

다른 플랫폼

  1. Vercel에서 저장소 가져오기
  2. 빌드 설정 구성:
    • Framework Preset: Astro
    • Build Command: npm run build
    • Output Directory: dist
  3. 배포

Docker

Docker 컨테이너로 블로그를 실행할 수 있습니다. 마크다운 폴더와 setting.toml만 마운트하면 동기화, 빌드, 서빙을 컨테이너가 자동으로 처리합니다.

사전 요구사항

빠른 시작

  1. setting.toml에서 source_root_path 설정

    컨테이너에서 마크다운 폴더는 /source에 마운트되므로, 경로를 맞춰야 합니다:

    setting.toml
    source_root_path = "/source"
  2. Docker 이미지 빌드

    Terminal window
    docker build -t girok-md .
  3. 컨테이너 실행

    Terminal window
    docker run -d -p 8080:8080 \
    -v /마크다운/폴더/경로:/source:ro \
    -v ./setting.toml:/app/setting.toml:ro \
    girok-md
    • /마크다운/폴더/경로를 실제 마크다운 파일 폴더 경로로 변경하세요
    • :ro는 읽기 전용으로, 원본 파일을 수정하지 않습니다
    • http://localhost:8080에서 블로그에 접속할 수 있습니다

Docker Compose 사용

더 간편하게 docker-compose.yml을 편집하고 한 줄로 실행할 수 있습니다:

docker-compose.yml
services:
blog:
build: .
ports:
- "8080:8080"
volumes:
- /마크다운/폴더/경로:/source:ro
- ./setting.toml:/app/setting.toml:ro
Terminal window
docker compose up -d

동작 방식

컨테이너 시작 시 세 단계를 순서대로 실행합니다:

  1. 동기화/source에서 마크다운 파일을 프로젝트로 복사
  2. 빌드 — 정적 HTML 페이지와 검색 인덱스 생성
  3. 서빙 — Nginx 웹 서버가 8080 포트에서 빌드된 사이트 제공

콘텐츠 변경 후 재빌드

컨테이너는 시작 시 한 번만 빌드합니다. 새로운 마크다운 파일을 반영하려면 컨테이너를 재시작하세요:

Terminal window
docker compose down && docker compose up -d

수동 배포

로컬에서 빌드하고 정적 호스트에 업로드:

Terminal window
npm run build

빌드된 사이트는 dist/ 폴더에 있습니다:

  • 디렉터리dist/
    • index.html
    • 디렉터리posts/
      • 디렉터리my-first-post/
        • index.html
    • 디렉터리tags/
    • 디렉터리pagefind/
    • 디렉터리assets/
    • 디렉터리_astro/

dist/ 내용을 웹 서버에 업로드하세요.

빌드 설정

Base Path

하위 디렉토리에 배포하는 경우 (예: username.github.io/blog), astro.config.mjs 업데이트:

astro.config.mjs
export default defineConfig({
site: 'https://username.github.io',
base: '/blog',
// ...
});

환경 변수

프로덕션 빌드에서 환경 변수를 사용할 수 있습니다:

Terminal window
PUBLIC_SITE_URL=https://your-site.com npm run build