Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
10 changes: 10 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -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"
```
90 changes: 48 additions & 42 deletions TodoAPP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions app/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_HOST="yourhost.com"
DB_PORT="1234"
DB_NAME="yourDB"
DB_USER="dbUser"
DB_PASS="super$ecureP!ssword"
18 changes: 12 additions & 6 deletions app/src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
9 changes: 8 additions & 1 deletion app/src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down