๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

[Step by Step Tutorial] 10. Deployment

Deployment


์ด์ œ ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„๋กœ ์‚ฌ์ดํŠธ๋ฅผ ๋ฐฐํฌํ•  ์ค€๋น„๊ฐ€ ๋˜์—ˆ๋‹ค.


Gemfile#


์‚ฌ์ดํŠธ์— Gemfile์„ ๊ฐ–๊ณ  ์žˆ๋Š” ๊ฒƒ์€ ์ข‹์€ ๊ด€์Šต์ด๋‹ค. ์ด๊ฒƒ์€ Jekyll์˜ ๋ฒ„์ ผ์„ ํ™•์‹คํ•˜๊ฒŒํ•ด์ฃผ๊ณ , ๋‹ค๋ฅธ ํ™˜๊ฒฝ์—์„œ gem๋“ค์ด ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๊ฒŒ ํ•ด์ค€๋‹ค.

Gemfile ์„ ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋งŒ๋“ ๋‹ค.

source 'https://rubygems.org'
gem 'jekyll'

๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ ํ„ฐ๋ฏธ๋„์—์„œ bundle install ์„ ์‹คํ–‰ํ•œ๋‹ค. ์ด๊ฒƒ์€ gems๋ฅผ ์„ค์น˜ํ•˜๊ณ , Gemfile.lock ์„ ๋งŒ๋“ ๋‹ค. Gemfile.lock ์€ ํ˜„์žฌ์˜ gem ๋ฒ„์ ผ์„ ๋‹ค์Œ์— ์žˆ์„ bundle install ์ „๊นŒ์ง€ ๊ณ ์ •์‹œํ‚จ๋‹ค. ๋งŒ์•ฝ gem ๋ฒ„์ ผ์„ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด bundle update ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค.

Gemfile ์„ ์‚ฌ์šฉํ•˜๋ฉด, ์ด์ œ jekyll serve ๋ช…๋ น์–ด ์•ž์— bundle exec ๋ช…๋ น์–ด๋ฅผ ๋ถ™์—ฌ์„œ ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค.

bundle exec jekyll serve

์ด๊ฒƒ์€ Gemfile ์— ์ •ํ•ด์ง„ gem๋“ค๋งŒ ์‚ฌ์šฉํ•˜๋„๋ก Ruby ํ™˜๊ฒฝ์„ ์ œํ•œํ•œ๋‹ค.


Plugins#


Jekyll์€ ๋งŽ์€ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. - Jekyll plugins

๊ทธ ์ค‘ ๊ฑฐ์˜ ๋ชจ๋“  Jekyll ์‚ฌ์ดํŠธ์—์„œ ์œ ์šฉํ•œ ์„ธ ๊ฐ€์ง€ ๊ณต์‹์ ์ธ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ์žˆ๋‹ค.

  • Jekyll-sitemap : ๊ฒ€์ƒ‰ ์—”์ง„์ด ์šฐ๋ฆฌ์˜ ์‚ฌ์ดํŠธ ์ฝ˜ํ…์ธ ๋ฅผ ์ž˜ ์ฐพ์„ ์ˆ˜ ์žˆ๋„๋ก sitemap์„ ๋งŒ๋“ค์–ด์ค€๋‹ค.

  • Jekyll-feed : ํฌ์ŠคํŠธ์˜ RSS feed๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค.

  • Jekyll-seo-tag : SEO๋ฅผ ์œ„ํ•ด meta tag๋“ค์„ ์ถ”๊ฐ€ํ•ด์ฃผ๋Š”๋ฐ ๋„์›€์„ ์ค€๋‹ค.

์ด ์„ธ ๊ฐ€์ง€ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ Gemfile ์— ์ถ”๊ฐ€ํ•œ๋‹ค.

source 'https://rubygems.org'
gem 'jekyll'
group :jekyll_plugins do  gem 'jekyll-sitemap'  gem 'jekyll-feed'  gem 'jekyll-seo-tag'end

๊ทธ๋ฆฌ๊ณ  _config.yml ์—๋„ ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•œ๋‹ค.

plugins:  - jekyll-feed  - jekyll-sitemap  - jekyll-seo-tag

๊ทธ๋ฆฌ๊ณ  ์ด์ œ bundle update ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.

jekyll-sitemap ์€ ์ด๊ฒƒ๋งŒ์œผ๋กœ sitemap์„ ๋นŒ๋“œ์‹œ์— ๋งŒ๋“ค์–ด๋‚ธ๋‹ค.

jekyll-feed ์™€ jekyll-seo-tag ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” _layouts/default.html ์— ๋”ฐ๋กœ ํƒœ๊ทธ๋ฅผ ์ถ”๊ฐ€ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.

<!DOCTYPE html><html>    <head>        <meta charset="utf-8" />        <title>{{ page.title }}</title>        <link rel="stylesheet" href="/assets/css/styles.css" />        {% feed_meta %} {% seo %}    </head>    <body>        {% include navigation.html %} {{ content }}    </body></html>

Jekyll ์„œ๋ฒ„๋ฅผ ์žฌ์‹œ์ž‘ํ•˜๊ณ  <head> ์— ํƒœ๊ทธ๊ฐ€ ์ž˜ ์ถ”๊ฐ€๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.


Environments#


๋•Œ๋•Œ๋กœ ์‚ฌ์ดํŠธ๋ฅผ ๋งŒ๋“ค์—ˆ์„ ๋•Œ๋Š” ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•˜๊ณ  ์‹ถ์ง€๋งŒ, ๊ฐœ๋ฐœ ์ค‘์ผ ๋•Œ๋Š” ํ‘œ์‹œํ•˜์ง€ ์•Š๊ณ  ์‹ถ์„ ์ˆ˜ ์žˆ๋‹ค. disqus ๋˜๋Š” Google Analytics ๋“ฑ์ด ๊ทธ๋Ÿฌํ•œ๋ฐ, ์ด๊ฒƒ์„ ์œ„ํ•ด์„œ๋Š” environments๋ฅผ ์‚ฌ์šฉํ• ์ˆ˜์žˆ๋‹ค.

JEKYLL_ENV ๋ผ๋Š” ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

JEKYLL_ENV=production bundle exec jekyll build

๊ธฐ๋ณธ์ ์œผ๋กœ JEKYLL_ENV ๋Š” development๋กœ ๋˜์–ด์žˆ๋‹ค. JEKYLL_ENV ๋Š” liquid ๋ฌธ๋ฒ•์œผ๋กœ jekyll.environment ๋กœ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋‹ค. ๋”ฐ๋ผ์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•˜๋ฉด analytics script๋ฅผ production์‹œ์—๋งŒ ํ‘œ์‹œํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค.

{% if jekyll.environment == "production" %}<script src="my-analytics-script.js"></script>{% endif %}

Deployment#


๋งˆ์ง€๋ง‰์œผ๋กœ ์‚ฌ์ดํŠธ ์‚ฐ์ถœ๋ฌผ์„ ์„œ๋ฒ„๋กœ ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ์˜๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

JEKYLL_ENV=production bundle exec jekyll build

๊ทธ๋ฆฌ๊ณ  ์ด ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ด์„œ ๋งŒ๋“ค์–ด์ง„ _site ๋””๋ ‰ํ† ๋ฆฌ์˜ ์ฝ˜ํ…์ธ ๋ฅผ ๋ณต์‚ฌํ•ด ์„œ๋ฒ„๋กœ์ œ๊ณตํ•œ๋‹ค.

๋” ์ข‹์€ ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” CI ๋˜๋Š” ์„œ๋“œํŒŒํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค.