        ![Blue and white line art of woman at desktop with the Drupal logo on the computer monitor in front of her](/sites/default/files/styles/blog_hero_image_mobile/public/media/image/2022-08/Option%2002.png?itok=h9sKqeWt) 

 

 

 Image

        ![Dries Buytaert Headshot](/sites/default/files/styles/post_content_attribution_headshot/public/media/image/2024-09/Employee%20Headshot_Dries%20Buytaert_Gray_WEB.png?h=ba226ffe&itok=eze7g_Ik) 

 

 

 

 [Dries Buytaert](/people/contributors/dries-buytaert) Co-Founder, Executive Chairman Acquia

 

 

 

 

 



# Drupal創設者が行う、Drupalデプロイワークフローの紹介

 September 9, 2022 1 分で読めます

 [Share this blog post on LinkedIn

 ](https://www.linkedin.com/sharing/share-offsite/?url=https://www.acquia.com/index%2ephp/jp/markdownify/node/38616) [Share this blog post on Twitter

 ](https://twitter.com/intent/tweet?text=Drupal創設者が行う、Drupalデプロイワークフローの紹介&url=https://www.acquia.com/index%2ephp/jp/markdownify/node/38616&via=acquia) [Share this blog post via Email

 ](mailto:?subject=Drupal創設者が行う、Drupalデプロイワークフローの紹介&body=https://www.acquia.com/index%2ephp/jp/markdownify/node/38616) 

 

 Drupal、アクイアの創設者であるドリス・バイタルトが行なっているデプロイワークフローを紹介します。 

        ![Blue and white line art of woman at desktop with the Drupal logo on the computer monitor in front of her](/sites/default/files/styles/blog_hero_image_mobile/public/media/image/2022-08/Option%2002.png?itok=h9sKqeWt) 

 

 

この記事では、私の個人サイトである[dri.es](https://dri.es/)で使用している開発とデプロイのワークフローの概要を説明したいと思います。

このサイトは（当然ですが）[Drupal](https://www.drupal.org/)が使用されており、（もちろん）[Acquia Cloud Platform](https://www.acquia.com/products/drupal-cloud/cloud-platform)上でホスティングされていますが、これはWebアプリケーションのベストプラクティスの多くを取り入れています。

Webサイトのコードベースと設定を[Git](https://en.wikipedia.org/wiki/Git)で管理しています。 Gitリポジトリに変更をコミットする度に、必ず次のステップを踏みます。

1. 本番環境にデプロイする前にコードをテストするために、ステージング環境を作成します。 PHP、MySQL、Nginxだけでなく、VarnishやMemcacheなどが入っており本番サイトに限りなく近い構成になっています。
2. Gitリポジトリをチェックアウトします。 Gitリポジトリは、カスタムファイルのみを管理します。 DrupalコアやサードパーティのDrupalモジュールは、Gitリポジトリにコミットしないのがベストプラクティスです。
3. [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer)を実行して、カスタムコードがコーディングルールに準拠していることを確認します。 `phpcs.xml`でコーディングスタイルのルールを指定して、`phpcs`コマンドを走らせてチェックします。 ルールに準拠していないコードが見つかった場合、`phpcbf`コマンドを使用して自動的に整形します。 これで、コーディングルールに準拠したコードが保たれます。
4. PHPの静的コード解析ツールである[PHPStan](https://phpstan.org/)を実行して、コードベースにバグがないか走査します。 デッドコード、型変換の問題、関数の引数の間違い、型ヒントの欠落、不明な関数呼び出しなど、多くの問題を発見することができます。 PHPStanは素晴らしいツールです。
5. PHPのテストフレームワークである[PHP Unit](https://phpunit.de/)を実行して、ユニットテストが合格することを確認します。
6. カスタムコードに対して、PHPの静的コード解析ツールである[phpcs-security-audit](https://github.com/FloeDesignTechnologies/phpcs-security-audit)を実行します。 これはPHPコードにセキュリティ上の脆弱性や弱点がないか走査するものです。
7. カスタムコードに対して、JavaScriptの静的コード解析ツールである[ESLint](https://eslint.org/)を実行します。 これはJavaScriptコードにセキュリティ上の脆弱性や弱点がないか走査するものです。
8. [nodejs-scan](https://github.com/ajinabraham/njsscan)を実行します。これはNode.jsアプリケーションの危険なコードパターンを発見します。 今の所、Node.jsは使っていませんが。
9. 様々なプログラミング言語に対応した静的コード解析ツールの[Semgrep](https://semgrep.dev/)も実行します。
10. [Rector](https://www.drupal.org/project/rector)を実行します。これは[非推奨のDrupalコード](https://www.drupal.org/list-changes/drupal)を検知します。 非推奨コードが検出されると、自動修正を試行します。
11. 私のGitリポジトリではカスタムコードのみを管理しているので、[Composer](https://getcomposer.org/)を使って最新版のDrupalとサードパーティのモジュール、コンポーネントを全てダウンロードしてインストールするようにしています。
12. `drush pm:security`を実行します。[Drush](https://www.drush.org/)はDrupalのコマンドラインツールです。`pm:security`コマンドは、[危険な依存関係がインストールされていないか](https://github.com/drupal-composer/drupal-security-advisories)検査するものです。

この全てを、コミットのたびに手動で実行するのは非現実的です。CI/CDツールを使えば自動で行われますが、これらのベストプラクティスが盛り込まれた定義ファイルが用意されていると良さそうだと思いませんか？ アクイアは、アクイアの全ての顧客/パートナーのために[Acquia Code Studio](https://youtu.be/f8llAAcj4U8)をリリースしました。これは上記の全てのステップを追加の設定無しで自動化します。 Acquia Code Studioは、[Gitlab](https://gitlab.com/)をベースとしたフルマネージドなGitリポジトリです。Drupalに最適化されたCI/CDパイプラインを備えています。 私は20年以上Drupalに取り組んでいますが、これは最高の[WebOps](https://en.wikipedia.org/wiki/Web_operations)ワークフローです。 これ以上ないほど簡単です。

Image

 ![Screenshot of Acquia Code Studio that shows its automated tests feature](/sites/default/files/styles/wysiwyg_full_no_crop_/public/media/image/2022-08/Screen%20Shot%202022-08-11%20at%202.51.23%20PM.png?itok=0-VuJNBo)

 



A screenshot of Acquia Code Studio that shows its automated tests featureAcquia Code Studio は、依存関係の更新を自動化することもできます。 Code Studioは、Drupalやその依存ファイルが新しいリリースを利用可能かどうかを定期的にチェックします。 新しいリリースがある場合は、上記のすべての手順が実行されます。 上記のステップが*すべて*合格すると、マージリクエストのボタンを1回クリックするだけで、Acquia Code Studioは新しいコードを本番環境にデプロイすることができます。

Image

 ![Screenshot of Acquia Code Studio that shows its automated update feature](/sites/default/files/styles/wysiwyg_full_no_crop_/public/media/image/2022-08/Screen%20Shot%202022-08-11%20at%202.55.07%20PM.png?itok=M_OguqgZ)

 



A screenshot of Acquia Code Studio that shows its automated update feature最高です！

—

*この元記事は [My Drupal deployment workflow](https://dri.es/my-drupal-deployment-workflow) で掲載されています。 Drupalとアクイアの詳細は、[こちらのページ](https://www.acquia.com/drupal)をご覧ください。*



 

 Image

        ![Dries Buytaert Headshot](/sites/default/files/styles/post_content_attribution_headshot/public/media/image/2024-09/Employee%20Headshot_Dries%20Buytaert_Gray_WEB.png?h=ba226ffe&itok=eze7g_Ik) 

 

 

 

 [Dries Buytaert](/people/contributors/dries-buytaert) Co-Founder, Executive Chairman Acquia

 

Dries Buytaert is the original creator and project lead for Drupal and co-founder of Acquia. A noted expert in open source, he holds a PhD in computer science and engineering and has been honored as a Young Global Leader by the World Economic Forum.

 

 

 

 

 [Share this blog post on LinkedIn

 ](https://www.linkedin.com/sharing/share-offsite/?url=https://www.acquia.com/index%2ephp/jp/markdownify/node/38616) [Share this blog post on Twitter

 ](https://twitter.com/intent/tweet?text=Drupal創設者が行う、Drupalデプロイワークフローの紹介&url=https://www.acquia.com/index%2ephp/jp/markdownify/node/38616&via=acquia) [Share this blog post via Email

 ](mailto:?subject=Drupal創設者が行う、Drupalデプロイワークフローの紹介&body=https://www.acquia.com/index%2ephp/jp/markdownify/node/38616)