diff --git a/srcs/phpmyadmin/Dockerfile b/srcs/phpmyadmin/Dockerfile new file mode 100644 index 0000000..de0ecdb --- /dev/null +++ b/srcs/phpmyadmin/Dockerfile @@ -0,0 +1,35 @@ +FROM alpine +RUN sleep 10 +RUN apk update +RUN apk add openssl +RUN apk add nginx +RUN apk add php7 +RUN apk add php7-fpm +RUN apk add php7-mysqli +RUN apk add php7-gd +RUN apk add php7-mbstring +RUN apk add php7-curl +RUN apk add php7-json +RUN apk add php7-xml +RUN apk add php7-zip +RUN apk add php7-iconv +RUN apk add php7-session +RUN apk add telegraf +COPY srcs/start.sh /root/start.sh +COPY srcs/nginx.conf /etc/nginx/nginx.conf +COPY srcs/telegraf.conf /etc/telegraf/telegraf.conf +COPY srcs/phpmyadmin.conf /var/www/phpmyadmin/config.inc.php +WORKDIR /root/ +RUN wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-english.tar.gz +RUN tar -xvf phpMyAdmin-5.1.1-english.tar.gz +RUN mv phpMyAdmin-5.1.1-english/* /var/www/phpmyadmin/ +RUN mkdir -p /var/www/phpmyadmin/tmp +RUN chown -R root:root /var/www +RUN openssl genrsa -out nginx.key +RUN openssl req -new -key nginx.key -out nginx.csr -subj "/C=NL/ST=Friesland/L=Heerenveen/O=localhost/OU=localhost/CN=localhost/emailAddress=djonker@student.codam.nl" +RUN openssl x509 -req -days 365 -in nginx.csr -signkey nginx.key -out nginx.crt +RUN mv nginx.crt /etc/ssl/certs/nginx.crt +RUN mv nginx.key /etc/ssl/private/nginx.key +RUN chmod 600 /etc/ssl/certs/nginx.crt /etc/ssl/private/nginx.key +CMD sh start.sh +EXPOSE 5000/tcp diff --git a/srcs/phpmyadmin/deployment.yaml b/srcs/phpmyadmin/deployment.yaml new file mode 100644 index 0000000..03bd0f1 --- /dev/null +++ b/srcs/phpmyadmin/deployment.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpadmin + labels: + app: phpadmin +spec: + replicas: 1 + selector: + matchLabels: + app: phpadmin + template: + metadata: + labels: + app: phpadmin + spec: + containers: + - name: phpadmin + image: phpadmin + imagePullPolicy: Never + livenessProbe: + exec: + command: + - /bin/sh + - -c + - 'pgrep telegraf && pgrep php-fpm7 && pgrep nginx' diff --git a/srcs/phpmyadmin/service.yaml b/srcs/phpmyadmin/service.yaml new file mode 100644 index 0000000..1b8a2b8 --- /dev/null +++ b/srcs/phpmyadmin/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: phpadmin +spec: + type: LoadBalancer + selector: + app: phpadmin + ports: + - name: phpadmin + protocol: TCP + port: 5000 + nodePort: 5000 diff --git a/srcs/phpmyadmin/srcs/nginx.conf b/srcs/phpmyadmin/srcs/nginx.conf new file mode 100644 index 0000000..d95e5d6 --- /dev/null +++ b/srcs/phpmyadmin/srcs/nginx.conf @@ -0,0 +1,48 @@ +user root; +worker_processes auto; + +error_log /var/log/nginx/error.log; +error_log /var/log/nginx/error.log notice; +error_log /var/log/nginx/error.log info; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + access_log /var/log/nginx/access.log; + sendfile on; + keepalive_timeout 3600; + gzip on; + gzip_comp_level 6; + gzip_vary on; + gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype; + + server { + listen 5000 ssl default_server; + ssl_certificate /etc/ssl/certs/nginx.crt; + ssl_certificate_key /etc/ssl/private/nginx.key; + + root /var/www; + index index.php index.html index.htm; + server_name localhost; + + location / { + autoindex on; + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include fastcgi.conf; + include fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + } + + if ($scheme = http) { + return 301 https://$server_name$request_uri; + } + } +} diff --git a/srcs/phpmyadmin/srcs/phpmyadmin.conf b/srcs/phpmyadmin/srcs/phpmyadmin.conf new file mode 100644 index 0000000..ca701c3 --- /dev/null +++ b/srcs/phpmyadmin/srcs/phpmyadmin.conf @@ -0,0 +1,153 @@ +. + */ + +declare(strict_types=1); + +/** + * This is needed for cookie based authentication to encrypt password in + * cookie. Needs to be 32 chars long. + */ +$cfg['blowfish_secret'] = 'flsbdihjkuvydfsbkhjufdghiluiossd'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ + +/** + * Servers configuration + */ +$i = 0; + +/** + * First server + */ +$i++; +/* Authentication type */ +$cfg['Servers'][$i]['auth_type'] = 'cookie'; +/* Server parameters */ +$cfg['Servers'][$i]['host'] = 'mariadb'; +$cfg['Servers'][$i]['compress'] = false; +$cfg['Servers'][$i]['AllowNoPassword'] = false; + +/** + * phpMyAdmin configuration storage settings. + */ + +/* User used to manipulate with storage */ +// $cfg['Servers'][$i]['controlhost'] = ''; +// $cfg['Servers'][$i]['controlport'] = ''; +// $cfg['Servers'][$i]['controluser'] = 'pma'; +// $cfg['Servers'][$i]['controlpass'] = 'pmapass'; + +/* Storage database and tables */ +// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; +// $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; +// $cfg['Servers'][$i]['relation'] = 'pma__relation'; +// $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; +// $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; +// $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; +// $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; +// $cfg['Servers'][$i]['history'] = 'pma__history'; +// $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; +// $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; +// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; +// $cfg['Servers'][$i]['recent'] = 'pma__recent'; +// $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; +// $cfg['Servers'][$i]['users'] = 'pma__users'; +// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; +// $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; +// $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; +// $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; +// $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; +// $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates'; + +/** + * End of servers configuration + */ + +/** + * Directories for saving/loading files from server + */ +$cfg['UploadDir'] = ''; +$cfg['SaveDir'] = ''; + +/** + * Whether to display icons or text or both icons and text in table row + * action segment. Value can be either of 'icons', 'text' or 'both'. + * default = 'both' + */ +//$cfg['RowActionType'] = 'icons'; + +/** + * Defines whether a user should be displayed a "show all (records)" + * button in browse mode or not. + * default = false + */ +//$cfg['ShowAll'] = true; + +/** + * Number of rows displayed when browsing a result set. If the result + * set contains more rows, "Previous" and "Next". + * Possible values: 25, 50, 100, 250, 500 + * default = 25 + */ +//$cfg['MaxRows'] = 50; + +/** + * Disallow editing of binary fields + * valid values are: + * false allow editing + * 'blob' allow editing except for BLOB fields + * 'noblob' disallow editing except for BLOB fields + * 'all' disallow editing + * default = 'blob' + */ +//$cfg['ProtectBinary'] = false; + +/** + * Default language to use, if not browser-defined or user-defined + * (you find all languages in the locale folder) + * uncomment the desired line: + * default = 'en' + */ +//$cfg['DefaultLang'] = 'en'; +//$cfg['DefaultLang'] = 'de'; + +/** + * How many columns should be used for table display of a database? + * (a value larger than 1 results in some information being hidden) + * default = 1 + */ +//$cfg['PropertiesNumColumns'] = 2; + +/** + * Set to true if you want DB-based query history.If false, this utilizes + * JS-routines to display query history (lost by window close) + * + * This requires configuration storage enabled, see above. + * default = false + */ +//$cfg['QueryHistoryDB'] = true; + +/** + * When using DB-based query history, how many entries should be kept? + * default = 25 + */ +//$cfg['QueryHistoryMax'] = 100; + +/** + * Whether or not to query the user before sending the error report to + * the phpMyAdmin team when a JavaScript error occurs + * + * Available options + * ('ask' | 'always' | 'never') + * default = 'ask' + */ +//$cfg['SendErrorReports'] = 'always'; + +/** + * You can find more configuration options in the documentation + * in the doc/ folder or at . + */ diff --git a/srcs/phpmyadmin/srcs/start.sh b/srcs/phpmyadmin/srcs/start.sh new file mode 100644 index 0000000..78572f0 --- /dev/null +++ b/srcs/phpmyadmin/srcs/start.sh @@ -0,0 +1,4 @@ +#!/bin/sh +telegraf & +php-fpm7 & +nginx -g 'daemon off;' diff --git a/srcs/phpmyadmin/srcs/telegraf.conf b/srcs/phpmyadmin/srcs/telegraf.conf new file mode 100644 index 0000000..f51ba69 --- /dev/null +++ b/srcs/phpmyadmin/srcs/telegraf.conf @@ -0,0 +1,28 @@ +[global_tags] +[agent] + interval = "10s" + round_interval = true + metric_batch_size = 1000 + metric_buffer_limit = 10000 + collection_jitter = "0s" + flush_interval = "10s" + flush_jitter = "0s" + precision = "" + hostname = "" + omit_hostname = false +[[outputs.influxdb]] + urls = ["http://influxdb:8086"] + database = "phpadmin" +[[inputs.cpu]] + percpu = true + totalcpu = true + collect_cpu_time = false + report_active = false +[[inputs.disk]] + ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] +[[inputs.diskio]] +[[inputs.kernel]] +[[inputs.mem]] +[[inputs.processes]] +[[inputs.swap]] +[[inputs.system]]