Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f48879446c | |||
|
|
84ed9e478e | ||
|
|
c8a745f997 | ||
| ce6fcab5f3 |
@@ -5,6 +5,10 @@ on:
|
|||||||
- cron: '0 2 * * 1'
|
- cron: '0 2 * * 1'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_URL: https://git.cafepieters.com
|
||||||
|
OWNER: helmchart
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-and-release:
|
update-and-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -222,7 +226,9 @@ jobs:
|
|||||||
if: steps.check_update.outputs.php_updated == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
run: |
|
run: |
|
||||||
helm package .
|
helm package .
|
||||||
echo "Helm chart packaged"
|
CHART_FILE=$(ls *.tgz)
|
||||||
|
echo "CHART_FILE=${CHART_FILE}" >> $GITHUB_ENV
|
||||||
|
echo "Helm chart packaged: ${CHART_FILE}"
|
||||||
|
|
||||||
- name: Create Git Tag
|
- name: Create Git Tag
|
||||||
if: steps.check_update.outputs.php_updated == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
@@ -258,54 +264,18 @@ jobs:
|
|||||||
echo "Release created"
|
echo "Release created"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Update Helm Repository Index
|
- name: Publish to Gitea Package Registry
|
||||||
if: steps.check_update.outputs.php_updated == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
echo "🚀 Publishing ${CHART_FILE} to Gitea Package Registry..."
|
||||||
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
|
||||||
CHART_NAME=$(grep '^name:' Chart.yaml | awk '{print $2}')
|
|
||||||
PACKAGE_FILE="${CHART_NAME}-${APP_VERSION}.tgz"
|
|
||||||
|
|
||||||
echo "Preparing Helm repository update..."
|
curl --fail-with-body \
|
||||||
|
-u "${{ secrets.REGISTRY_USER }}:${{ secrets.REGISTRY_TOKEN }}" \
|
||||||
|
-X POST \
|
||||||
|
--upload-file "${CHART_FILE}" \
|
||||||
|
"${REGISTRY_URL}/api/packages/${OWNER}/helm/api/charts"
|
||||||
|
|
||||||
# パッケージファイルを一時ディレクトリに移動
|
echo "✅ Chart published successfully!"
|
||||||
mkdir -p /tmp/helm-repo
|
|
||||||
cp "${PACKAGE_FILE}" /tmp/helm-repo/
|
|
||||||
|
|
||||||
# gh-pagesブランチの処理
|
|
||||||
if git ls-remote --heads origin gh-pages | grep gh-pages; then
|
|
||||||
echo "gh-pages branch exists, checking out..."
|
|
||||||
git fetch origin gh-pages
|
|
||||||
git checkout gh-pages
|
|
||||||
else
|
|
||||||
echo "Creating new gh-pages branch..."
|
|
||||||
git checkout --orphan gh-pages
|
|
||||||
git rm -rf . || true
|
|
||||||
echo "# Helm Repository" > README.md
|
|
||||||
git add README.md
|
|
||||||
git config user.name "GitHub Actions Bot"
|
|
||||||
git config user.email "actions@github.com"
|
|
||||||
git commit -m "Initialize gh-pages branch"
|
|
||||||
git push origin gh-pages
|
|
||||||
fi
|
|
||||||
|
|
||||||
# パッケージファイルをコピー
|
|
||||||
cp /tmp/helm-repo/"${PACKAGE_FILE}" .
|
|
||||||
|
|
||||||
# index.yamlを生成/更新
|
|
||||||
helm repo index . --url "https://git.cafepieters.com/${GITHUB_REPOSITORY}/raw/branch/gh-pages"
|
|
||||||
|
|
||||||
# コミットしてプッシュ
|
|
||||||
git config user.name "GitHub Actions Bot"
|
|
||||||
git config user.email "actions@github.com"
|
|
||||||
git add "${PACKAGE_FILE}" index.yaml
|
|
||||||
git commit -m "chore: add ${CHART_NAME} v${APP_VERSION}" || echo "No changes to commit"
|
|
||||||
git push origin gh-pages
|
|
||||||
|
|
||||||
echo "Helm repository updated successfully"
|
|
||||||
|
|
||||||
# mainブランチに戻る
|
|
||||||
git checkout main
|
|
||||||
|
|
||||||
- name: Summary
|
- name: Summary
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: steps.check_update.outputs.update_needed == 'true'
|
||||||
|
|||||||
38
CLAUDE.md
Normal file
38
CLAUDE.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# CLAUDE.md — phpfpm Helm Chart
|
||||||
|
|
||||||
|
## リポジトリ概要
|
||||||
|
|
||||||
|
Raspberry Pi などのベアメタルで稼働することを想定した、Kubernetes 上で動作する Nginx + PHP-FPM の Helm チャート。
|
||||||
|
|
||||||
|
- **Gitea リポジトリ**: `ssh://git@192.168.9.65/helmchart/phpfpm`
|
||||||
|
- **Helm リポジトリ**: `https://git.cafepieters.com/api/packages/helmchart/helm`
|
||||||
|
|
||||||
|
## 実行環境について
|
||||||
|
|
||||||
|
**PHP の実行環境(インタープリタ)はこのリポジトリには含まれていない。**
|
||||||
|
チャートは `docker.io/php:<tag>-fpm-alpine` の公式イメージを Kubernetes 上で起動するものであり、PHP コードそのものは PVC(`/var/www/html`)に別途配置する必要がある。
|
||||||
|
|
||||||
|
## Git コミット情報
|
||||||
|
|
||||||
|
| 項目 | 値 |
|
||||||
|
|------|-----|
|
||||||
|
| 名前 | Claude |
|
||||||
|
| メール | claude@cafepieters.com |
|
||||||
|
| SSH キー | `P:\Claude\.ssh\id_claude` |
|
||||||
|
|
||||||
|
## チャート改修履歴
|
||||||
|
|
||||||
|
### phpEnv — 汎用 PHP 環境変数サポート(2026-04-17)
|
||||||
|
|
||||||
|
`values.yaml` に `phpEnv` セクションを追加し、DB 接続情報と同様に任意のキーと値を PHP-FPM コンテナの環境変数として渡せるようにした。
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
phpEnv:
|
||||||
|
API_KEY: "your-api-key"
|
||||||
|
STRIPE_SECRET: "sk_live_..."
|
||||||
|
REDIS_URL: "redis://localhost:6379"
|
||||||
|
```
|
||||||
|
|
||||||
|
PHP 側では `$_ENV['API_KEY']` または `getenv('API_KEY')` で取得できる。
|
||||||
|
|
||||||
|
**対象ファイル**: `values.yaml`, `templates/deployment.yaml`, `README.md`
|
||||||
@@ -2,6 +2,6 @@ apiVersion: v2
|
|||||||
name: phpfpm
|
name: phpfpm
|
||||||
description: Nginx + PHP-FPM Helm Chart with external DB and optional Selenium support
|
description: Nginx + PHP-FPM Helm Chart with external DB and optional Selenium support
|
||||||
type: application
|
type: application
|
||||||
version: 8.5.4
|
version: 8.5.5
|
||||||
appVersion: "8.5.4"
|
appVersion: "8.5.5"
|
||||||
icon: https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/PHP-logo.svg/330px-PHP-logo.svg.png
|
icon: https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/PHP-logo.svg/330px-PHP-logo.svg.png
|
||||||
|
|||||||
46
README.md
46
README.md
@@ -147,6 +147,14 @@ kubectl logs -l app.kubernetes.io/name=phpfpm -c nginx
|
|||||||
| `externalDatabase.username` | ユーザー名 | `user` |
|
| `externalDatabase.username` | ユーザー名 | `user` |
|
||||||
| `externalDatabase.password` | パスワード | `pass` |
|
| `externalDatabase.password` | パスワード | `pass` |
|
||||||
|
|
||||||
|
### PHP 汎用環境変数(phpEnv)
|
||||||
|
|
||||||
|
| パラメータ | 説明 | デフォルト |
|
||||||
|
|-----------|------|-----------|
|
||||||
|
| `phpEnv` | PHP-FPM コンテナに渡す任意の環境変数(キーと値のマップ) | `{}` |
|
||||||
|
|
||||||
|
PHP 側では `$_ENV['KEY']` または `getenv('KEY')` で取得できます。
|
||||||
|
|
||||||
### SMTP設定
|
### SMTP設定
|
||||||
|
|
||||||
| パラメータ | 説明 | デフォルト |
|
| パラメータ | 説明 | デフォルト |
|
||||||
@@ -564,7 +572,43 @@ helm install production-api cafepieters/phpfpm \
|
|||||||
--set externalDatabase.password=$(kubectl get secret db-password -o jsonpath='{.data.password}' | base64 -d)
|
--set externalDatabase.password=$(kubectl get secret db-password -o jsonpath='{.data.password}' | base64 -d)
|
||||||
```
|
```
|
||||||
|
|
||||||
### 例10: SMTP設定によるメール送信
|
### 例10: APIキーなどの任意環境変数を PHP に渡す(phpEnv)
|
||||||
|
|
||||||
|
`phpEnv` を使うと、DB 接続情報と同様に任意のキーと値を PHP-FPM コンテナの環境変数として渡せます。
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# values.yaml
|
||||||
|
phpEnv:
|
||||||
|
API_KEY: "your-api-key"
|
||||||
|
STRIPE_SECRET: "sk_live_xxxxxxxxxxxxxxxx"
|
||||||
|
REDIS_URL: "redis://localhost:6379"
|
||||||
|
EXTERNAL_SERVICE_URL: "https://api.example.com"
|
||||||
|
```
|
||||||
|
|
||||||
|
**PHPでの使用例**:
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
// $_ENV または getenv() で取得
|
||||||
|
$apiKey = getenv('API_KEY');
|
||||||
|
$stripe = $_ENV['STRIPE_SECRET'];
|
||||||
|
$redisUrl = getenv('REDIS_URL');
|
||||||
|
|
||||||
|
echo "API Key: " . $apiKey;
|
||||||
|
```
|
||||||
|
|
||||||
|
**確認コマンド**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 設定された環境変数を確認
|
||||||
|
kubectl exec -it <pod-name> -c php-fpm -- env | grep -E "API_|STRIPE_|REDIS_"
|
||||||
|
```
|
||||||
|
|
||||||
|
**注意事項**:
|
||||||
|
- 機密性の高い値(APIキー、シークレット等)は `--set phpEnv.KEY=value` でデプロイ時に注入するか、Kubernetes の Secret を別途作成して参照することを推奨します。
|
||||||
|
- `phpEnv` の値はすべてプレーンテキストとして環境変数に設定されます(externalDatabase の password のみ Secret 経由)。
|
||||||
|
|
||||||
|
### 例11: SMTP設定によるメール送信
|
||||||
|
|
||||||
PHPアプリケーションからSMTP経由でメール送信を行う設定です。
|
PHPアプリケーションからSMTP経由でメール送信を行う設定です。
|
||||||
|
|
||||||
|
|||||||
@@ -220,6 +220,10 @@ spec:
|
|||||||
name: {{ include "phpfpm.fullname" . }}-db-secret
|
name: {{ include "phpfpm.fullname" . }}-db-secret
|
||||||
key: {{ include "phpfpm.fullname" . }}-db-key
|
key: {{ include "phpfpm.fullname" . }}-db-key
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- range $key, $value := .Values.phpEnv }}
|
||||||
|
- name: {{ $key }}
|
||||||
|
value: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
{{- if .Values.selenium.enabled }}
|
{{- if .Values.selenium.enabled }}
|
||||||
- name: selenium
|
- name: selenium
|
||||||
image: "{{ .Values.image.selenium.registry }}/{{ .Values.image.selenium.repository }}:{{ .Values.image.selenium.tag }}"
|
image: "{{ .Values.image.selenium.registry }}/{{ .Values.image.selenium.repository }}:{{ .Values.image.selenium.tag }}"
|
||||||
|
|||||||
15
values.yaml
15
values.yaml
@@ -4,17 +4,17 @@ image:
|
|||||||
nginx:
|
nginx:
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
repository: nginx
|
repository: nginx
|
||||||
tag: "1.29.6-alpine-perl"
|
tag: "1.29.8-alpine-perl"
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
php:
|
php:
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
repository: php
|
repository: php
|
||||||
tag: "8.5.4-fpm-alpine3.23"
|
tag: "8.5.5-fpm-alpine3.23"
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
selenium:
|
selenium:
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
repository: selenium/standalone-chromium
|
repository: selenium/standalone-chromium
|
||||||
tag: "145.0-chromedriver-145.0"
|
tag: "147.0-chromedriver-147.0"
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
service:
|
service:
|
||||||
@@ -174,3 +174,12 @@ smtp:
|
|||||||
allowSelfSigned: false
|
allowSelfSigned: false
|
||||||
|
|
||||||
resources: {}
|
resources: {}
|
||||||
|
|
||||||
|
# PHP-FPM コンテナに渡す任意の環境変数
|
||||||
|
# DB接続情報(externalDatabase)と同様に、values.yamlで設定した値がPHPに環境変数として渡される
|
||||||
|
# PHPからは $_ENV['KEY'] または getenv('KEY') で取得可能
|
||||||
|
phpEnv: {}
|
||||||
|
# API_KEY: "your-api-key"
|
||||||
|
# STRIPE_SECRET: "sk_live_xxxxxxxxxxxxxxxx"
|
||||||
|
# REDIS_URL: "redis://localhost:6379"
|
||||||
|
# SOME_SERVICE_URL: "https://api.example.com"
|
||||||
Reference in New Issue
Block a user