VPSにKamalでWordpressをデプロイしました。
その設定ファイルです。
ヘルスチェックを解決しないといけないので、Dockerfileでヘルスチェック用のPHPをアップしています。
Dockerfile
FROM wordpress:latest
COPY up.php /var/www/html/up.php
EXPOSE 80
deploy.yml
service: xxxxxx_com_wp
image: xxxxxx/xxxxxx_com_wp
registry:
username: xxxxxx
password:
- KAMAL_REGISTRY_PASSWORD
servers:
web:
hosts:
- {IP}
proxy:
ssl: true
app_port: 80
host: {ホスト}
healthcheck:
path: /up.php
builder:
arch: amd64
env:
clear:
WORDPRESS_DB_HOST: xxxxxx_com_wp-db # サービス名-アクセサリ名
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: example
WORDPRESS_DB_PASSWORD: examplepassword
# volumes:
# - "wordpress:/var/www/html"
accessories:
db:
image: mysql:8.4
host: {IP}
env:
MYSQL_DATABASE: wordpress
MYSQL_USER: example
MYSQL_PASSWORD: examplepassword
MYSQL_RANDOM_ROOT_PASSWORD: '1'
directories:
- data:/var/lib/mysql
up.php
<?php
header('Content-Type: application/json');
http_response_code(200);
echo json_encode(['healthy' => true]);
exit;
ハマったのはさくらVPSだとなぜかdbに接続できない…設定の問題なんだろうけれど…