From 037fb95bd357cd6ef5d370f98957f54ab11b2f28 Mon Sep 17 00:00:00 2001 From: Airdrop Celestia Confirmed Date: Thu, 7 Mar 2024 17:54:56 -0600 Subject: [PATCH 1/4] Added Dockefile --- Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6cf4a3b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Stage 1: Build PHP application +FROM php:7.4-apache + +# Set environment variables +ENV PHP_UPLOAD_MAX_FILESIZE 10M +ENV PHP_POST_MAX_SIZE 10M + +# Install MySQL client +RUN apt-get update && apt-get install -y default-mysql-client + +# Install mysqli and pdo_mysql extensions +RUN docker-php-ext-install mysqli pdo_mysql + +# Copy your source code to /var/www/html +COPY . /var/www/html + +# Configure Apache +COPY apache-config.conf /etc/apache2/sites-available/000-default.conf +RUN a2enmod rewrite +ENV APACHE_DOCUMENT_ROOT /var/www/html/public +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +# Expose port 80 +EXPOSE 80 + +# Start Apache +CMD ["apache2-foreground"] From 14ea7d95c748741eec5a78d0515f995743ddf193 Mon Sep 17 00:00:00 2001 From: Airdrop Celestia Confirmed Date: Wed, 13 Mar 2024 05:56:24 -0500 Subject: [PATCH 2/4] creating a config file and Dockerfile --- configmap | 15 +++++++++++++++ dockerfile.ms1 | 25 +++++++++++++++++++++++++ dockerfile.ms2 | 16 ++++++++++++++++ mysql-initdb-config | 17 +++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 configmap create mode 100644 dockerfile.ms1 create mode 100644 dockerfile.ms2 create mode 100644 mysql-initdb-config diff --git a/configmap b/configmap new file mode 100644 index 0000000..94d1e2e --- /dev/null +++ b/configmap @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql-initdb-config +data: + initdb.sql: | + CREATE TABLE friends ( + id INT, + name VARCHAR(256), + age INT, + gender VARCHAR(3) + ); + INSERT INTO friends VALUES (1, 'John Smith', 32, 'm'); + INSERT INTO friends VALUES (2, 'Lilian Worksmith', 29, 'f'); + INSERT INTO friends VALUES (3, 'Michael Rupert', 27, 'm'); diff --git a/dockerfile.ms1 b/dockerfile.ms1 new file mode 100644 index 0000000..661a653 --- /dev/null +++ b/dockerfile.ms1 @@ -0,0 +1,25 @@ +# Stage 1: Build Stage +FROM php:7.4-apache AS build + +# Install mysqli extension +RUN docker-php-ext-install mysqli + +# Stage 2: Production Stage +FROM php:7.4-apache + +# Copy the built mysqli extension from the build stage +COPY --from=build /usr/local/lib/php/extensions/no-debug-non-zts-20190902/mysqli.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/mysqli.so + +# Enable the mysqli extension +RUN echo "extension=mysqli.so" > /usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini + +# Copy source code to /var/www/html +COPY src/ /var/www/html/ + +# Update database connection string to point to the Kubernetes service named mysql-service +# Assuming the connection is in a PHP file, you may need to replace the appropriate string +# Example: If your connection string is in config.php +# RUN sed -i 's/old_connection_string/new_connection_string/g' /var/www/html/config.php + +# Expose port 80 +EXPOSE 80 diff --git a/dockerfile.ms2 b/dockerfile.ms2 new file mode 100644 index 0000000..fc98686 --- /dev/null +++ b/dockerfile.ms2 @@ -0,0 +1,16 @@ +# Stage 1: Build environment for installing dependencies +FROM php:7.4-apache AS builder + +RUN apt-get update && apt-get install -y mysqli && apt-get clean + +# Stage 2: Copy application code and configure database connection +FROM php:7.4-apache + +# Copy source code to Apache document root +COPY . /var/www/html + +# Update database connection string (replace 'config.php' with your actual file) +RUN sed -i 's/DATABASE_HOST.*/DATABASE_HOST=mysql-service/g' /var/www/html/config.php + +# Expose port 80 for web traffic +EXPOSE 80 \ No newline at end of file diff --git a/mysql-initdb-config b/mysql-initdb-config new file mode 100644 index 0000000..59fca86 --- /dev/null +++ b/mysql-initdb-config @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Pod +metadata: + name: mysql +spec: + containers: + - name: mysql + image: mysql + ports: + - containerPort: 3306 + volumeMounts: + - name: mysql-initdb + mountPath: /docker-entrypoint-initdb.d + volumes: + - name: mysql-initdb + configMap: + name: mysql-initdb-config From db4ad8aee92cc0ae1630c171d38b6057a3ba9aad Mon Sep 17 00:00:00 2001 From: Airdrop Celestia Confirmed Date: Wed, 27 Mar 2024 19:06:50 -0500 Subject: [PATCH 3/4] Update README.md Replicaset deletion --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 8ab1a70..77e3b87 100644 --- a/README.md +++ b/README.md @@ -123,3 +123,13 @@ sudo sed -i 's/172.20.1.101/localhost/g' /var/www/html/index.php ``` curl http://localhost ``` + +### Delete a Replicaset + +```sh +kubectl describe -f rs/go-demo-2.yml + +kubectl delete replicaset + +``` + From 2ff081cc7c7f7db5a8d931385b041091f4170c86 Mon Sep 17 00:00:00 2001 From: Airdrop Celestia Confirmed Date: Wed, 27 Mar 2024 19:09:54 -0500 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77e3b87..18d2a5c 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ curl http://localhost ```sh kubectl describe -f rs/go-demo-2.yml -kubectl delete replicaset +kubectl delete replicaset --cascade=orphan ```