From e89a756e4bda530134e37f45be9c3be6f1373459 Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Sat, 11 Nov 2023 07:20:54 +1000 Subject: [PATCH] Add the Docker Compose configuration files This is the initial configuration, applicable to a single environment. --- compose.yml | 29 +++++++++++ docker/database/Dockerfile | 3 ++ docker/database/dump.sql | 104 +++++++++++++++++++++++++++++++++++++ docker/nginx/default.conf | 51 ++++++++++++++++++ docker/php/Dockerfile | 3 ++ 5 files changed, 190 insertions(+) create mode 100644 compose.yml create mode 100644 docker/database/Dockerfile create mode 100644 docker/database/dump.sql create mode 100644 docker/nginx/default.conf create mode 100644 docker/php/Dockerfile diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..ceac221 --- /dev/null +++ b/compose.yml @@ -0,0 +1,29 @@ +services: + nginx: + image: nginx:1.25.3-alpine + ports: + - 8080:80 + volumes: + - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf + - .:/var/www/html + php: + build: + dockerfile: docker/php/Dockerfile + volumes: + - .:/var/www/html + database: + build: + dockerfile: docker/database/Dockerfile + ports: + - "3306:3306" + environment: + MARIADB_ROOT_PASSWORD: password + MARIADB_DATABASE: hawaii-five-0 + MARIADB_USER: user + MARIADB_PASSWORD: password + volumes: + - database_data:/var/lib/mysql + +volumes: + database_data: + driver: local diff --git a/docker/database/Dockerfile b/docker/database/Dockerfile new file mode 100644 index 0000000..6815222 --- /dev/null +++ b/docker/database/Dockerfile @@ -0,0 +1,3 @@ +FROM mariadb:11.1.2-jammy + +COPY ./docker/database/dump.sql /docker-entrypoint-initdb.d/dump.sql diff --git a/docker/database/dump.sql b/docker/database/dump.sql new file mode 100644 index 0000000..6653ef6 --- /dev/null +++ b/docker/database/dump.sql @@ -0,0 +1,104 @@ +-- MySQL dump 10.13 Distrib 8.0.27, for macos11.6 (x86_64) +-- +-- Host: localhost Database: project_db +-- ------------------------------------------------------ +-- Server version 8.0.27 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `actors` +-- + +DROP TABLE IF EXISTS `actors`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `actors` ( + `id` int NOT NULL AUTO_INCREMENT, + `first_name` varchar(200) NOT NULL, + `last_name` varchar(200) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `actors_first_name_last_name_uindex` (`first_name`,`last_name`) +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `actors` +-- + +LOCK TABLES `actors` WRITE; +/*!40000 ALTER TABLE `actors` DISABLE KEYS */; +INSERT INTO `actors` VALUES (1,'Alex','O\'Loughlin'),(11,'Beulah','Koale'),(6,'Chi','McBride'),(4,'Daniel','Dae Kim'),(15,'Dennis','Chun'),(5,'Grace','Park'),(7,'Ian','Anthony Dale'),(8,'Jorge','Garcia'),(13,'Kimee','Balmilero'),(9,'Masi','Oka'),(10,'Meaghan','Rath'),(12,'Michelle','Borth'),(2,'Scott','Caan'),(3,'Taylor','Willy'),(14,'Teilor','Grubbs'); +/*!40000 ALTER TABLE `actors` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `character_to_actor` +-- + +DROP TABLE IF EXISTS `character_to_actor`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `character_to_actor` ( + `character_id` int NOT NULL, + `actor_id` int NOT NULL, + PRIMARY KEY (`character_id`,`actor_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `character_to_actor` +-- + +LOCK TABLES `character_to_actor` WRITE; +/*!40000 ALTER TABLE `character_to_actor` DISABLE KEYS */; +INSERT INTO `character_to_actor` VALUES (2,1),(3,2),(4,3),(5,4),(6,5),(7,6),(8,15),(9,9),(10,8),(11,7),(12,12),(13,11),(14,10),(15,13); +/*!40000 ALTER TABLE `character_to_actor` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `characters` +-- + +DROP TABLE IF EXISTS `characters`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `characters` ( + `id` int NOT NULL, + `first_name` varchar(200) COLLATE utf8_bin NOT NULL, + `last_name` varchar(200) COLLATE utf8_bin NOT NULL, + `title` varchar(5) COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `characters_first_name_last_name_index` (`first_name`,`last_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `characters` +-- + +LOCK TABLES `characters` WRITE; +/*!40000 ALTER TABLE `characters` DISABLE KEYS */; +INSERT INTO `characters` VALUES (2,'Steve','McGarrett',NULL),(3,'Danny','Williams',NULL),(4,'Kamekona','',NULL),(5,'Chin Ho','Kelly',NULL),(6,'Kono','Kalakaua',NULL),(7,'Lou','Grover',NULL),(8,'Duke','Lukela','Sgt.'),(9,'Max','Bergman',NULL),(10,'Jerry','Ortega',NULL),(11,'Adam','Noshimuri',NULL),(12,'Catherine','Rollins',NULL),(13,'Junior','Reigns',NULL),(14,'Tani','Rey',NULL),(15,'Noelani','Cunha','Dr.'); +/*!40000 ALTER TABLE `characters` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2021-11-24 20:20:57 diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..5bd98bd --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,51 @@ +server { + + # Set the port to listen on and the server name + listen 80 default_server; + + # Set the document root of the project + root /var/www/html/public; + + # Set the directory index files + index index.php; + + # Specify the default character set + charset utf-8; + + # Setup the default location configuration + location / { + try_files $uri $uri/ /index.php; + } + + # Specify the details of favicon.ico + location = /favicon.ico { access_log off; log_not_found off; } + + # Specify the details of robots.txt + location = /robots.txt { access_log off; log_not_found off; } + + # Specify the logging configuration + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + sendfile off; + + client_max_body_size 100m; + + # Specify what happens when PHP files are requested + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param APPLICATION_ENV development; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + } + + # Specify what happens what .ht files are requested + location ~ /\.ht { + deny all; + } +} diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 0000000..3a81788 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,3 @@ +FROM php:8.2-fpm + +RUN docker-php-ext-install pdo_mysql