Browse Source

save 22-11-28

master
nicolas-arnaud 2 years ago
parent
commit
b75f782453
  1. 1
      .gitignore
  2. 1
      Makefile
  3. 11
      README.md
  4. 26
      srcs/.env
  5. 4
      srcs/bonus/gitea/start.sh
  6. 11
      srcs/bonus/hexo/README.md
  7. 14
      srcs/wordpress/Dockerfile
  8. 19
      srcs/wordpress/start.sh
  9. 4
      srcs/wordpress/www.conf

1
.gitignore

@ -1,2 +1 @@
srcs/.env
inception.pem

1
Makefile

@ -19,6 +19,7 @@ $(CERT):
mv inception.pem $(DATA_FOLDER)/ssl
start: $(CERT)
mkdir -p $(DATA_FOLDER)/www/wordpress
docker compose -f srcs/docker-compose.yml up --build
debug: $(CERT)

11
README.md

@ -1,10 +1,11 @@
# Inception
## Subject:
### Mandatory:
Contenairize a web server which will host wordpresss localy with docker on alpine/debian base.
Server must be nginx and database mariadb. All services must be on their own containers
### Bonus:
Handle wordpress cache with redis, add adminer, add an ftp server and another service of your choice (gitea)
Projet 42:
Sujet: Conteneuriser un serveur web qui hebergera wordpress localement à l'aide de docker, alpine/debian, nginx et mariadb
## Todo:
- add login/register/admin buttons in wordpress
## Instructions:
### Setup it:

26
srcs/.env

@ -0,0 +1,26 @@
DOMAIN=narnaud.42.fr
#DOMAIN=localhost
MYSQL_ROOT_PWD=mariadbword
WP_DATABASE_NAME=wordpress
WP_DATABASE_USR=maria
WP_DATABASE_PWD=mariaword
GITEA_DATABASE_NAME=giteadb
GITEA_DATABASE_USR=gitea
GITEA_DATABASE_PWD=giteaword
WP_TITLE=Inception
WP_ADMIN_USR=theboss
WP_ADMIN_PWD=thebossword
WP_ADMIN_EMAIL=nicolas.rr.arnaud@gmail.com
WP_USR=narnaud
WP_PWD=narnaudword
WP_EMAIL=narnaud@student.42nice.fr
FTP_USR=ftpuser
FTP_PWD=ftpuserword
GITEA_ADMIN_USR=theboss
GITEA_ADMIN_PWD=thebossword
GITEA_ADMIN_MAIL=nicolas.rr.arnaud@gamil.com

4
srcs/bonus/gitea/start.sh

@ -3,7 +3,7 @@
while ! mariadb -hmariadb -u$GITEA_DATABASE_USR -p$GITEA_DATABASE_PWD $GITEA_DATABASE_NAME &>/dev/null; do
echo "Gitea waiting db..."
sleep 5
sleep 30
done
if [ ! -f "app.ini.bak" ]; then
@ -17,4 +17,4 @@ if [ ! -f "app.ini.bak" ]; then
gitea admin user create --username $GITEA_ADMIN_USR --password $GITEA_ADMIN_PWD --email $GITEA_ADMIN_MAIL --admin
fi
echo "Launching gitea on localhost:3000"
gitea web --config /etc/gitea/app.ini &> /dev/null
gitea web --config /etc/gitea/app.ini

11
srcs/bonus/hexo/README.md

@ -1,10 +1,11 @@
# Inception
## Subject:
### Mandatory:
Contenairize a web server which will host wordpresss localy with docker on alpine/debian base.
Server must be nginx and database mariadb. All services must be on their own containers
### Bonus:
Handle wordpress cache with redis, add adminer, add an ftp server and another service of your choice (gitea)
Projet 42:
Sujet: Conteneuriser un serveur web qui hebergera wordpress localement à l'aide de docker, alpine/debian, nginx et mariadb
## Todo:
- add login/register/admin buttons in wordpress
## Instructions:
### Setup it:

14
srcs/wordpress/Dockerfile

@ -9,17 +9,19 @@ RUN apk update && apk upgrade && apk add --no-cache \
php8-shmop php8-simplexml php8-soap php8-sockets php8-sodium php8-sqlite3 php8-sysvsem \
php8-sysvshm php8-tokenizer php8-xml php8-xmlreader php8-xmlwriter php8-xsl php8-zip php8-zlib
RUN adduser -S nginx && addgroup -S nginx
COPY php-fpm.conf /etc/php8/php-fpm.conf
COPY www.conf /etc/php8/php-fpm.d/www.conf
RUN addgroup -g 1000 nginx && adduser -u 1000 -G nginx -D nginx
RUN wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
RUN chmod +x wp-cli.phar
RUN cp wp-cli.phar /usr/bin/wp
RUN ln -s /usr/bin/php8 /usr/bin/php
WORKDIR /var/www/wordpress/
COPY php-fpm.conf /etc/php8/php-fpm.conf
COPY www.conf /etc/php8/php-fpm.d/www.conf
COPY start.sh /tmp/start.sh
WORKDIR /var/www/wordpress/
RUN chown -hR 1000:1000 /var/www /etc/php8 /var/log/php8 /run \
&& chmod -R g+wrx /var/www /etc/php* /var/log/php8 /run
USER 1000
ENTRYPOINT [ "sh", "/tmp/start.sh" ]

19
srcs/wordpress/start.sh

@ -3,13 +3,12 @@ while ! mariadb -hmariadb -u$WP_DATABASE_USR -p$WP_DATABASE_PWD $WP_DATABASE_NAM
echo "Wordpress waiting db..."
sleep 5
done
if [ ! -f "index.php" ]; then
wp core download --allow-root
wp config create --dbname=$WP_DATABASE_NAME --dbuser=$WP_DATABASE_USR --dbpass=$WP_DATABASE_PWD --dbhost=mariadb --dbcharset="utf8" --dbcollate="utf8_general_ci" --allow-root
wp core install --url=https://$DOMAIN/wordpress --title=$WP_TITLE --admin_user=$WP_ADMIN_USR --admin_password=$WP_ADMIN_PWD --admin_email=$WP_ADMIN_EMAIL --skip-email --allow-root
wp user create $WP_USR $WP_EMAIL --role=author --user_pass=$WP_PWD --allow-root
wp theme install generatepress --activate --allow-root
wp core download
wp config create --dbname=$WP_DATABASE_NAME --dbuser=$WP_DATABASE_USR --dbpass=$WP_DATABASE_PWD --dbhost=mariadb --dbcharset="utf8" --dbcollate="utf8_general_ci"
wp core install --url=https://$DOMAIN/wordpress --title=$WP_TITLE --admin_user=$WP_ADMIN_USR --admin_password=$WP_ADMIN_PWD --admin_email=$WP_ADMIN_EMAIL --skip-email
wp user create $WP_USR $WP_EMAIL --role=author --user_pass=$WP_PWD
wp theme install generatepress --activate
wp widget add meta sidebar-1 1
sed -i "90i define('WP_REDIS_HOST', 'redis');" wp-config.php
@ -18,9 +17,9 @@ if [ ! -f "index.php" ]; then
sed -i "93i define('WP_REDIS_READ_TIMEOUT', 1);" wp-config.php
sed -i "94i define('WP_REDIS_DATABASE', 0);" wp-config.php
wp plugin install redis-cache --activate --allow-root
wp plugin update --all --allow-root
wp plugin install redis-cache --activate
wp plugin update --all
wget -O adminer.php https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1-mysql-en.php
fi
wp redis enable --allow-root
/usr/sbin/php-fpm8 -R &> /dev/null
wp redis enable
/usr/sbin/php-fpm8 -R

4
srcs/wordpress/www.conf

@ -1,10 +1,8 @@
[www]
user = nginx
group = nginx
listen = 9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_spare_servers = 3

Loading…
Cancel
Save