0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自作ブログ作成への動きだしにGhost触ってみた

Last updated at Posted at 2024-07-23

どうも、アスカです。JAWSUG_初心者支部2024年3月27日の山下さんの講演を受け、自作ブログシステムを作ってホストしたいと思っていたんですが、Amplify Gen2やらAmazon Bedrockやら触りたいアップデートが多く、なかなか踏み出せずにいました。先延ばしは良くないのでここらで動きだそうと思います。
本記事では第一候補にしていたGhostを触っていきます。
Ghost

選んだ理由はデザインがスタイリッシュで用意されているデザイン格好良いだけでなく、APIドキュメンテーションや開発者向けの資料が豊富であると感じた点にあります。加えてAmazon SESとの連携など機能も豊富だと感じました。お試しの触りでコンテナを使っていきたいと思います。

開発環境

ローカルのWSL2+Dockerを使っていきます。手元のノートPCはWinodwsでDocker CE利用のための環境は作成済みです。ここでは環境作成まで説明しません。以下の記事を参考にしてください。
https://qiita.com/haveAbook/items/0d0ae20a19214f65e7cd

ちなみに本記事作成時の環境は

  • Ubuntu 22.04
  • Docker 27.1.0

でした。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
$ docker --version
Docker version 27.1.0, build 6312585

Compose.ymlを作成する。

任意のフォルダでcompose.ymlを作成します。ここではGhostのDockerを管理しているコミュニティページからコピーしてきます。
https://hub.docker.com/_/ghost/

compose.yml
version: '3.1'

services:

  ghost:
    image: ghost:5-alpine
    restart: always
    ports:
      - 8080:2368
    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: example
      database__connection__database: ghost
      # this url value is just an example, and is likely wrong for your environment!
      url: http://localhost:8080
      # contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)
      #NODE_ENV: development
    volumes:
      - ghost:/var/lib/ghost/content

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
    volumes:
      - db:/var/lib/mysql

volumes:
  ghost:
  db:

ghostのサーバ自体と同時に使うDBを立てる内容になっています。
早速実行してみましょう。
compose.ymlを保存したフォルダで以下のDockerコマンドを実行します。

$ docker compose up -d

これでcompose.ymlを参照してコンテナを立ち上げます。

$ docker compose up -d
[+] Running 24/24
 ✔ db 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                              89.4s
   ✔ d9a40b27c30f Already exists                                                                                   0.0s
   ✔ 7d8ccc83ce1d Pull complete                                                                                    0.7s
   ✔ f98ae2ef29c4 Pull complete                                                                                    0.8s
   ✔ 2e1aa9898aa1 Pull complete                                                                                    1.5s
   ✔ d0229fb4f83e Pull complete                                                                                    1.4s
   ✔ bdfea4c359d4 Pull complete                                                                                    1.6s
   ✔ d6fe59aa1e5c Pull complete                                                                                    7.8s
   ✔ 7336dce1c47f Pull complete                                                                                    2.2s
   ✔ 1c71c9d185d1 Pull complete                                                                                   10.0s
   ✔ e63d4802c63b Pull complete                                                                                    3.1s
   ✔ 383f329967ab Pull complete                                                                                    4.3s
 ✔ ghost 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                          152.6s
   ✔ b84a74cde5af Already exists                                                                                   0.0s
   ✔ 736e98ba7a5c Already exists                                                                                   0.0s
   ✔ 8acd99c863c5 Already exists                                                                                   0.0s
   ✔ 947e87cde9c3 Already exists                                                                                   0.0s
   ✔ 736555ebc3a6 Pull complete                                                                                    5.3s
   ✔ 4c30ca2ad003 Pull complete                                                                                    6.7s
   ✔ dc0f8a9b7faf Pull complete                                                                                    7.6s
   ✔ c1041f3d4317 Pull complete                                                                                   12.3s
   ✔ 883e006fc179 Pull complete                                                                                   23.3s
   ✔ 4f4fb700ef54 Pull complete                                                                                   10.4s
   ✔ fb57ea63914d Pull complete                                                                                   11.9s
[+] Running 2/5
 ⠇ Network asuka_default    Created                                                                                8.9s
 ⠸ Volume "asuka_db"        Created                                                                                8.3s
 ⠙ Volume "asuka_ghost"     Created                                                                                8.2s
 ✔ Container asuka-ghost-1  Started                                                                                8.1s
 ✔ Container asuka-db-1     Started                            

これでコンテナが立ち上がっているはずです。compose.ymlの設定上ローカルの8080ポートへのアクセスをコンテナの2368ポートフォワーディングする設定になっているので,
http://localhost:8080 にアクセスしてみます。
以下の画面が表示されました。アプリとして起動はしていそうです。
スタイリッシュでかっこ良いです...
画像
次に管理者画面にアクセスしてみます。
http://localhost:8080/ghost/ にアクセスすると
http://localhost:8080/ghost/#/setup/ にリダイレクトされ、以下の情報等登録画面が表示されした。
画像
ここではタイトルに"アスカのログ部屋"と名付けました。
登録が終わると以下のような管理者画面が表示されました。
画像
サイドバー等を見ると、この画面から記事の作成やデザイン変更などが出来そうです。

総じて

あまり細かい要件がある訳ではないので、これでGhostで十分では?と思ってしまいます。ヘッドレスCMSとしても使用出来るようですし...
ローカルですがDockerを使って実装が出来たので次回はAmazon ECS?AWS Fargate?で実行してみようと思います!コンテナの練習もしてみたかったんでちょうど良いです。
それでは、本記事はこれで~

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?