aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile27
-rw-r--r--srcs/nginx_conf/ft_server.com (renamed from srcs/nginx_conf/test.com)13
-rwxr-xr-xsrcs/scripts/docker_entrypoint.sh7
-rwxr-xr-xsrcs/scripts/generate_certificates.sh10
-rwxr-xr-xsrcs/scripts/wordpress_setup.sql5
-rw-r--r--srcs/wordpress/wp-config.php4
6 files changed, 48 insertions, 18 deletions
diff --git a/Dockerfile b/Dockerfile
index d6a48cf..4018114 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,27 +4,24 @@ RUN apt update && \
apt install -y nginx \
php-fpm \
mariadb-server \
- php-mysql
- # php-mbstring \
- # php-gettext
-
-COPY srcs/nginx_conf /etc/nginx/sites-available/
+ php-mysql \
+ php-mbstring \
+ curl
RUN mkdir /var/www/wordpress /var/www/phpmyadmin
COPY srcs/wordpress /var/www/wordpress
COPY srcs/phpmyadmin /var/www/phpmyadmin
-RUN ln -fs /etc/nginx/sites-available/test.com /etc/nginx/sites-enabled/default
+COPY srcs/nginx_conf /etc/nginx/sites-available/
+RUN rm /etc/nginx/sites-enabled/default && \
+ ln -fs /etc/nginx/sites-available/ft_server.com /etc/nginx/sites-enabled/ft_server.com
-EXPOSE 80
+COPY srcs/scripts /root/scripts
RUN service mysql start && \
- echo "CREATE DATABASE testdb;" | mysql -u root && \
- echo "CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';" | mysql -u root && \
- echo "GRANT ALL PRIVILEGES ON testdb.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';" | mysql -u root && \
- echo "FLUSH PRIVILEGES;" | mysql -u root
+ mysql -u root < /root/scripts/wordpress_setup.sql && \
+ sh /root/scripts/generate_certificates.sh
+
+EXPOSE 80
-CMD service php7.3-fpm start && \
- service mysql start && \
- service nginx start && \
- sleep infinity & wait
+CMD ["/root/scripts/docker_entrypoint.sh"]
diff --git a/srcs/nginx_conf/test.com b/srcs/nginx_conf/ft_server.com
index b9d9de2..b04e470 100644
--- a/srcs/nginx_conf/test.com
+++ b/srcs/nginx_conf/ft_server.com
@@ -1,5 +1,10 @@
server {
- listen 80;
+ 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;
@@ -28,3 +33,9 @@ server {
}
}
+server {
+ listen 80;
+ listen [::]:80;
+ server_name localhost;
+ return 301 https://$host$request_uri;
+}
diff --git a/srcs/scripts/docker_entrypoint.sh b/srcs/scripts/docker_entrypoint.sh
new file mode 100755
index 0000000..ebcd5a2
--- /dev/null
+++ b/srcs/scripts/docker_entrypoint.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+service mysql start
+service php7.3-fpm start
+service nginx start
+sleep infinity &
+wait
diff --git a/srcs/scripts/generate_certificates.sh b/srcs/scripts/generate_certificates.sh
new file mode 100755
index 0000000..29afef7
--- /dev/null
+++ b/srcs/scripts/generate_certificates.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+cd /root
+mkdir ssl
+cd ssl
+
+curl -L https://github.com/FiloSottile/mkcert/releases/download/v1.1.2/mkcert-v1.1.2-linux-amd64 > mkcert
+chmod +x mkcert
+./mkcert -install
+./mkcert localhost
diff --git a/srcs/scripts/wordpress_setup.sql b/srcs/scripts/wordpress_setup.sql
new file mode 100755
index 0000000..b0fc867
--- /dev/null
+++ b/srcs/scripts/wordpress_setup.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/wordpress/wp-config.php b/srcs/wordpress/wp-config.php
index d15cf83..2c45c2d 100644
--- a/srcs/wordpress/wp-config.php
+++ b/srcs/wordpress/wp-config.php
@@ -20,13 +20,13 @@
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
-define( 'DB_NAME', 'testdb' );
+define( 'DB_NAME', 'wordpressdb' );
/** MySQL database username */
define( 'DB_USER', 'wordpressuser' );
/** MySQL database password */
-define( 'DB_PASSWORD', 'password' );
+define( 'DB_PASSWORD', 'wordpresspass' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );