ft_server tutorial — 42 project

.
├── Dockerfile
└── srcs/
Dockerfile                  | Makefile
----------------------------------------------------------------
docker build . | make
image_id | a.out
docker run image_id | ./a.out
FROM debian:buster
RUN apt-get -y update                       
RUN apt-get -y install nginx \
mariadb-server \
php-fpm php-mysql \
wget dialog apt-utils \
php php-cgi php-mysqli php-pear php-mbstring php-gettext php-common php-phpseclib php-mysql
WORKDIR /var/www/localhost
COPY srcs/nginx.config /etc/nginx/sites-available/                       RUN ln -s /etc/nginx/sites-available/nginx.config /etc/nginx/sites-enabled/
COPY ./srcs/config.inc.php /var/www/myserver/phpmyadmin/                       COPY ./srcs/wp-config.php /var/www/myserver/wordpress/
RUN chown -R www-data:www-data ../**/**                       
RUN chown -R 755 /var/www/myserver
RUN chmod -R 755 /var/www/*
RUN openssl req -x509 -nodes -days 365 -subj "/C=BE/ST=Belgium/L=your_city/O=your_building/OU=your_office/CN=your_name" -newkey rsa:2048 -keyout /etc/ssl/nginx-selfsigned.key -out /etc/ssl/nginx-selfsigned.crt;
COPY ./srcs/init.sh ./                       
CMD /bin/bash ./init.sh
EXPOSE 80 443
service nginx start                       
service mysql start
service php7.3-fpm start

echo "CREATE DATABASE wordpress;"| mysql -u root --skip-password echo "GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' WITH GRANT OPTION;"| mysql -u root --skip-password echo "FLUSH PRIVILEGES;"| mysql -u root --skip-password echo "update mysql.user set plugin='' where user='root';"| mysql -u root --skip-password
#sleep infinity & wait # option 1
bash # option 2
Removing intermediate container c46df72a253f
---> aa89aa05b6d1
Successfully built aa89aa05b6d1 # of course the id will be different
docker ps -a # to find the name of the running container
docker container stop container_name
sed -i “s/autoindex on;/autoindex off;/g” /etc/nginx/sites-available/nginx.config 
service nginx restart
docker run exec <container_name> bash /myscript.sh

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store