diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..06d295f --- /dev/null +++ b/README @@ -0,0 +1,10 @@ + # .env + Write the env-file `.env.local` to the path `/home/deploy/deployments/TodoAPP/.env.local` of your server. + Example values: + ``` + DB_HOST="yourhost.com" + DB_PORT="1234" + DB_NAME="yourDB" + DB_USER="dbUser" + DB_PASS="super$ecureP!ssword" + ``` \ No newline at end of file diff --git a/TodoAPP.yaml b/TodoAPP.yaml index 0dc0d63..83be587 100644 --- a/TodoAPP.yaml +++ b/TodoAPP.yaml @@ -17,46 +17,52 @@ metadata: name: TodoAPP spec: containers: - - args: - - mysqld - env: - - name: MYSQL_ALLOW_EMPTY_PASSWORD - value: "1" - image: docker.io/library/mysql:8.4 - name: mysql - ports: - - containerPort: 80 - hostIP: 127.0.0.1 - hostPort: 8080 - volumeMounts: - - mountPath: /var/lib/mysql - name: caea52734591442fbd270c7b8306b4dae7b2d08af69eb8b38457fc85e1765b25-pvc - - args: - - valkey-server - image: docker.io/valkey/valkey:9-alpine - name: valkey - volumeMounts: - - mountPath: /data - name: 24f58da75852808673a4459f99d3c6e0754ecf374fcf45197ef7185305e43099-pvc - - args: - - php-fpm - image: localhost/todo-pod-fpm:latest - name: fpm - volumeMounts: - - mountPath: /app/public - name: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814-pvc - - image: localhost/todo-pod-caddy:latest - name: caddy - volumeMounts: - - mountPath: /app/public - name: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814-pvc + - args: + - mysqld + env: + - name: MYSQL_ALLOW_EMPTY_PASSWORD + value: "1" + image: docker.io/library/mysql:8.4 + name: mysql + ports: + - containerPort: 80 + hostIP: 127.0.0.1 + hostPort: 8080 + volumeMounts: + - mountPath: /var/lib/mysql + name: caea52734591442fbd270c7b8306b4dae7b2d08af69eb8b38457fc85e1765b25-pvc + - args: + - valkey-server + image: docker.io/valkey/valkey:9-alpine + name: valkey + volumeMounts: + - mountPath: /data + name: 24f58da75852808673a4459f99d3c6e0754ecf374fcf45197ef7185305e43099-pvc + - args: + - php-fpm + image: localhost/todo-pod-fpm:latest + name: fpm + volumeMounts: + - mountPath: /app/public + name: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814-pvc + - mountPath: /app/.env + name: env-file + - image: localhost/todo-pod-caddy:latest + name: caddy + volumeMounts: + - mountPath: /app/public + name: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814-pvc volumes: - - name: caea52734591442fbd270c7b8306b4dae7b2d08af69eb8b38457fc85e1765b25-pvc - persistentVolumeClaim: - claimName: caea52734591442fbd270c7b8306b4dae7b2d08af69eb8b38457fc85e1765b25 - - name: 24f58da75852808673a4459f99d3c6e0754ecf374fcf45197ef7185305e43099-pvc - persistentVolumeClaim: - claimName: 24f58da75852808673a4459f99d3c6e0754ecf374fcf45197ef7185305e43099 - - name: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814-pvc - persistentVolumeClaim: - claimName: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814 + - name: caea52734591442fbd270c7b8306b4dae7b2d08af69eb8b38457fc85e1765b25-pvc + persistentVolumeClaim: + claimName: caea52734591442fbd270c7b8306b4dae7b2d08af69eb8b38457fc85e1765b25 + - name: 24f58da75852808673a4459f99d3c6e0754ecf374fcf45197ef7185305e43099-pvc + persistentVolumeClaim: + claimName: 24f58da75852808673a4459f99d3c6e0754ecf374fcf45197ef7185305e43099 + - name: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814-pvc + persistentVolumeClaim: + claimName: 5f3187ed6462d7d25f0b13316001418ece4484668f5f4ac9c1575e2a16a33814 + - name: env-file + hostPath: + path: /home/deploy/deployments/TodoAPP/.env.local + type: File diff --git a/app/.env.template b/app/.env.template new file mode 100644 index 0000000..d97a513 --- /dev/null +++ b/app/.env.template @@ -0,0 +1,5 @@ +DB_HOST="yourhost.com" +DB_PORT="1234" +DB_NAME="yourDB" +DB_USER="dbUser" +DB_PASS="super$ecureP!ssword" diff --git a/app/src/Config.php b/app/src/Config.php index 3d553ff..b38c625 100644 --- a/app/src/Config.php +++ b/app/src/Config.php @@ -13,13 +13,19 @@ private function __construct( private readonly string $dbPass ) {} - public static function create(): self { + public static function create( + string $dbHost, + int $dbPort, + string $dbName, + string $dbUser, + string $dbPass + ): self { return new self( - '127.0.0.1', - 3306, - 'todo_demo', - 'root', - '' + $dbHost, + $dbPort, + $dbName, + $dbUser, + $dbPass ); } diff --git a/app/src/index.php b/app/src/index.php index cabe06e..f8ecc3f 100644 --- a/app/src/index.php +++ b/app/src/index.php @@ -23,8 +23,15 @@ session_start(); } +$env = parse_ini_file("../.env"); // Application configuration -$config = Config::create(); +$config = Config::create( + $env['DB_HOST'], + $env['DB_PORT'], + $env['DB_NAME'], + $env['DB_USER'], + $env['DB_PASS'] +); // Create containerless Slim app $app = AppFactory::create();