diff --git a/Dockerfile b/Dockerfile index bfbb32a..f6809cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,12 @@ WORKDIR /var/www # Installing needed packages RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - mysql-server \ + mysql-server-5.7 \ + nano \ nginx \ - php-fpm \ - php-mysql \ - php-cli \ + php7.2-fpm \ + php7.2-mysql \ + php7.2-cli \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /var/www/html \ && rm /etc/nginx/sites-enabled/default @@ -31,5 +32,5 @@ COPY /var/www/ /var/www/ RUN chown -R www-data:www-data /var/www # Expose Insecure Web, MySQL Server -EXPOSE 80 +EXPOSE 80 3306 CMD ["/bin/sh", "/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 4a0f5ef..ce3d439 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,15 @@ #!/bin/sh +# Starting base services echo "[ INFO ] Starting MySQL Server" service mysql start echo "[ INFO ] Starting PHP 7.2 Service" service php7.2-fpm start +# Running friendBook database setup script +echo "[ INFO ] Setting up friendBook database" +mysql -u root < /scripts/friendBook.sql + echo "[ INFO ] Starting nginx" nginx -g "daemon off;" # Foreground diff --git a/scripts/friendBook.sql b/scripts/friendBook.sql new file mode 100644 index 0000000..7271481 --- /dev/null +++ b/scripts/friendBook.sql @@ -0,0 +1,44 @@ +use friendBook; + +create table login( + username varchar(25), + pword varchar(25), + primary key(username)); + +create table contacts( + username varchar(25), + fname varchar(25), + lnam varchar(25), + primary key(username), + foreign key(username) references login(username)); + +create table messages( + messageID int, + sender varchar(25), + recipient varchar(25), + message text, + date date, + haveread varchar(1), + primary key(messageID), + foreign key(sender) references contacts(username), + foreign key(recipient) references contacts(username)); + +create table friendlist( + username varchar(25), + friend varchar(25), + confirm boolean); + +insert into login + values ('user1', 'password1'); +insert into login + values ('user2', 'password2'); + +insert into contacts + values ('user1', 'num1', 'uno'); +insert into contacts + values ('user2', 'num2', 'dos'); + +insert into messages + values ('1', 'user1', 'user2', 'hello, how are you', now(), 'Y'); +insert into messages + values ('2', 'user2', 'user1', 'im doing good, thanks', now(), 'N'); \ No newline at end of file diff --git a/var/www/phptest.php b/var/www/phptest.php index cdf9f10..507e96b 100644 --- a/var/www/phptest.php +++ b/var/www/phptest.php @@ -1,39 +1,39 @@ connect_error) { - die("Connection failed: " . $conn->connect_error); -} -echo "Connected successfully"; - -?> +// Current user +$user = "William"; // Testing with until we have login working
-