File tree Expand file tree Collapse file tree 4 files changed +78
-4
lines changed
Expand file tree Collapse file tree 4 files changed +78
-4
lines changed Original file line number Diff line number Diff line change 1+ FROM php:8.2-apache
2+
3+ # Install PDO MySQL extension
4+ RUN docker-php-ext-install pdo pdo_mysql
5+
6+ # Copy application source
7+ COPY . /var/www/html/
Original file line number Diff line number Diff line change 1+ # Anleitung zur Verwendung mit Podman
2+
3+ Dieses Projekt kann mit Podman und Podman Compose ausgeführt werden.
4+
5+ ## Voraussetzungen
6+
7+ - [ Podman] ( https://podman.io/ )
8+ - [ Podman Compose] ( https://github.com/containers/podman-compose ) (oder Docker Compose)
9+
10+ ## Starten der Container
11+
12+ Um die Anwendung zu starten, führen Sie den folgenden Befehl im Hauptverzeichnis des Projekts aus:
13+
14+ ``` bash
15+ podman-compose up --build
16+ ```
17+
18+ Oder, falls Sie ` docker-compose ` verwenden:
19+
20+ ``` bash
21+ docker-compose up --build
22+ ```
23+
24+ Die Anwendung ist dann unter [ http://localhost:8080 ] ( http://localhost:8080 ) erreichbar.
25+
26+ ## Datenbank
27+
28+ Die Datenbank wird automatisch mit der Datei ` router_game.sql ` initialisiert.
29+ Die Datenbankdaten werden in einem Volume ` db_data ` gespeichert.
30+
31+ ## Stoppen der Container
32+
33+ Um die Container zu stoppen und zu entfernen:
34+
35+ ``` bash
36+ podman-compose down
37+ ```
Original file line number Diff line number Diff line change 1+ version : ' 3.8'
2+
3+ services :
4+ db :
5+ image : mariadb:10
6+ container_name : router_game_db
7+ environment :
8+ MYSQL_ROOT_PASSWORD : rootpassword
9+ MYSQL_DATABASE : router_game
10+ MYSQL_USER : router_user
11+ MYSQL_PASSWORD : router_password
12+ volumes :
13+ - ./router_game.sql:/docker-entrypoint-initdb.d/init.sql
14+ - db_data:/var/lib/mysql
15+
16+ web :
17+ build : .
18+ container_name : router_game_web
19+ ports :
20+ - " 8080:80"
21+ environment :
22+ DB_HOST : db
23+ DB_NAME : router_game
24+ DB_USER : router_user
25+ DB_PASSWORD : router_password
26+ depends_on :
27+ - db
28+
29+ volumes :
30+ db_data :
Original file line number Diff line number Diff line change 22// save_highscore.php
33
44// Database configuration
5- $ host = 'localhost ' ;
6- $ dbname = 'router_game ' ;
7- $ username = 'root ' ;
8- $ password = '' ;
5+ $ host = getenv ( ' DB_HOST ' ) ?: 'localhost ' ;
6+ $ dbname = getenv ( ' DB_NAME ' ) ?: 'router_game ' ;
7+ $ username = getenv ( ' DB_USER ' ) ?: 'root ' ;
8+ $ password = getenv ( ' DB_PASSWORD ' ) ?: '' ;
99
1010// Create connection
1111try {
You can’t perform that action at this time.
0 commit comments