aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md12
-rwxr-xr-x[-rw-r--r--]setup.sh11
-rw-r--r--srcs/.keep0
-rw-r--r--srcs/docker-compose.yml9
-rw-r--r--srcs/mysql/Dockerfile18
-rwxr-xr-xsrcs/mysql/scripts/setup_mysql.sh8
-rwxr-xr-xsrcs/mysql/scripts/setup_mysql_db.sql5
-rw-r--r--srcs/nginx/ft_services.com41
-rw-r--r--srcs/phpmyadmin/Dockerfile (renamed from docker-compose.yml)0
9 files changed, 104 insertions, 0 deletions
diff --git a/README.md b/README.md
index 88756eb..2270ff5 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,15 @@
# ft_services
ft\_services project of school 42
+
+## Services
+
+- Kubernetes web dashboard
+- Ingress Controller
+- Nginx server
+- FTPS server
+- Wordpress website
+- MySQL database
+- Phpmyadmin
+- Grafana
+- InfluxDB
diff --git a/setup.sh b/setup.sh
index 1a24852..09b7c07 100644..100755
--- a/setup.sh
+++ b/setup.sh
@@ -1 +1,12 @@
#!/bin/sh
+
+if ! [ -x `command -v docker` ]; then
+ echo "Error: docker is not installed"
+ exit 1
+elif ! [ -x `command -v docker-compose` ]; then
+ echo "Error: docker-compose is not installed"
+ exit 1
+fi
+
+cd ./srcs
+docker-compose --project-name ft_services up
diff --git a/srcs/.keep b/srcs/.keep
deleted file mode 100644
index e69de29..0000000
--- a/srcs/.keep
+++ /dev/null
diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml
new file mode 100644
index 0000000..1eb8c47
--- /dev/null
+++ b/srcs/docker-compose.yml
@@ -0,0 +1,9 @@
+version: "3"
+services:
+ nginx:
+ image: "nginx:alpine"
+ ports:
+ - 80:80
+ mysql:
+ build: ./mysql/Dockerfile
+
diff --git a/srcs/mysql/Dockerfile b/srcs/mysql/Dockerfile
new file mode 100644
index 0000000..f863eeb
--- /dev/null
+++ b/srcs/mysql/Dockerfile
@@ -0,0 +1,18 @@
+FROM alpine:3.10
+
+ENV MYSQL_ROOT_PASSWORD root
+ENV MYSQL_DATABASE ft_services_db
+ENV MYSQL_USER ft_services_user
+ENV MYSQL_PASSWORD ft_services_password
+ENV MYSQL_USER_MONITORING monitoring
+ENV MYSQL_PASSWORD_MONITORING monitoring
+
+RUN apk update && \
+ apk add --no-cache mysql-client
+COPY ./scripts /root/scripts
+
+EXPOSE 3306
+
+# RUN /root/scripts/setup_mysql.sh
+
+CMD ["mysql"]
diff --git a/srcs/mysql/scripts/setup_mysql.sh b/srcs/mysql/scripts/setup_mysql.sh
new file mode 100755
index 0000000..56f767f
--- /dev/null
+++ b/srcs/mysql/scripts/setup_mysql.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+addgroup mysql mysql
+
+MYSQLD_DIR=/run/mysqld
+
+mkdir $MYSQLD_DIR
+chown mysql:mysql $MYSQL_DIR
diff --git a/srcs/mysql/scripts/setup_mysql_db.sql b/srcs/mysql/scripts/setup_mysql_db.sql
new file mode 100755
index 0000000..ea66998
--- /dev/null
+++ b/srcs/mysql/scripts/setup_mysql_db.sql
@@ -0,0 +1,5 @@
+CREATE DATABASE wordpressdb;
+CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'wordpresspass';
+GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wordpressuser'@'localhost'
+IDENTIFIED BY 'wordpresspass';
+FLUSH PRIVILEGES;
diff --git a/srcs/nginx/ft_services.com b/srcs/nginx/ft_services.com
new file mode 100644
index 0000000..b04e470
--- /dev/null
+++ b/srcs/nginx/ft_services.com
@@ -0,0 +1,41 @@
+server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+
+ ssl_certificate /root/ssl/localhost.pem;
+ ssl_certificate_key /root/ssl/localhost-key.pem;
+
+ server_name localhost;
+ index index.php;
+ root /var/www/wordpress;
+
+ location / {
+ try_files $uri $uri/ =404; # if uri or uri/ not valid, 404 error
+ }
+
+ # phpmyadmin path, change root
+ location /phpmyadmin {
+ root /var/www;
+ index index.php;
+ location ~ ^/phpmyadmin/(.+\.php)$ {
+ include snippets/fastcgi-php.conf;
+ fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
+ }
+ location ~ ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+ root /var/www;
+ }
+ }
+
+ # php files
+ location ~ \.php$ {
+ include snippets/fastcgi-php.conf; # include php fpm settings
+ fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; # socket where php fpm is running
+ }
+}
+
+server {
+ listen 80;
+ listen [::]:80;
+ server_name localhost;
+ return 301 https://$host$request_uri;
+}
diff --git a/docker-compose.yml b/srcs/phpmyadmin/Dockerfile
index e69de29..e69de29 100644
--- a/docker-compose.yml
+++ b/srcs/phpmyadmin/Dockerfile