wip trying to launch worpdress

This commit is contained in:
hugo gogo
2022-09-20 21:10:45 +02:00
parent 334092253f
commit ef8ce69dad
16 changed files with 105 additions and 158 deletions

View File

@@ -54,12 +54,14 @@ up: $(VOLUMES_D)
list: list:
@echo $(B_YELLOW)"\nimages:"$(RESET) @echo $(B_YELLOW)"\nimages:"$(RESET)
@$(SUDO) docker images -a @$(SUDO) docker images -a
@echo $(B_YELLOW)"\ncontainers:"$(RESET)
@$(SUDO) docker ps -a
@echo $(B_YELLOW)"\nvolumes:"$(RESET) @echo $(B_YELLOW)"\nvolumes:"$(RESET)
@$(SUDO) docker volume ls @$(SUDO) docker volume ls
@echo $(B_YELLOW)"\nvolumes content:"$(RESET)
@ls $(VOLUMES_D)
@echo $(B_YELLOW)"\nnetworks:"$(RESET) @echo $(B_YELLOW)"\nnetworks:"$(RESET)
@$(SUDO) docker network ls @$(SUDO) docker network ls
@echo $(B_YELLOW)"\ncontainers:"$(RESET)
@$(SUDO) docker ps -a
@echo "" @echo ""
# remove project images and containers not used # remove project images and containers not used

View File

@@ -28,10 +28,8 @@
--- ---
#### docker : #### docker :
- [docker starter guide](https://docs.docker.com/get-started/) - [docker compose man](https://docs.docker.com/compose/compose-file/#volumes)
- [docker compose volumes](https://docs.docker.com/compose/compose-file/#volumes) - [Dockerfile man](https://docs.docker.com/engine/reference/builder/)
- [docker glossaire](https://docs.docker.com/glossary/)
- [Dockerfile syntaxe](https://docs.docker.com/engine/reference/builder/)
- [determine the parent image](https://forums.docker.com/t/determine-the-parent-image/48611) - [determine the parent image](https://forums.docker.com/t/determine-the-parent-image/48611)
- [docker image from scratch](https://codeburst.io/docker-from-scratch-2a84552470c8) - [docker image from scratch](https://codeburst.io/docker-from-scratch-2a84552470c8)
- [build context and image context](https://stackoverflow.com/questions/55108649/what-is-app-working-directory-for-a-dockerfile/55109065#55109065) - [build context and image context](https://stackoverflow.com/questions/55108649/what-is-app-working-directory-for-a-dockerfile/55109065#55109065)

View File

@@ -15,7 +15,7 @@ services:
- inception - inception
ports: ports:
- "443:443" - "443:443"
- "80:80" # - "80:80"
build: ./requirements/nginx build: ./requirements/nginx
image: nginx image: nginx
container_name: nginx_container container_name: nginx_container
@@ -44,8 +44,8 @@ services:
env_file: ./.env env_file: ./.env
networks: networks:
- inception - inception
volumes: # volumes:
- wp_volume:/var/www/html # - wp_volume:/var/www/html
build: build:
context: ./requirements/wordpress context: ./requirements/wordpress
args: args:

View File

@@ -2,9 +2,11 @@
# FROM debian:buster # FROM debian:buster
# #
# # vim and bash for debug
# RUN apt update && apt install -y \ # RUN apt update && apt install -y \
# mariadb-client \ # mariadb-client \
# mariadb-server \ # mariadb-server \
# vim bash \
# && \ # && \
# rm -rf /var/lib/apt/lists/* # rm -rf /var/lib/apt/lists/*
# #

View File

@@ -23,8 +23,8 @@
# * Basic Settings # * Basic Settings
# #
user = mysql user = mysql
pid-file = /run/mysqld/mysqld.pid pid-file = /var/run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock socket = /var/run/mysqld/mysqld.sock
port = 3306 port = 3306
basedir = /usr basedir = /usr
datadir = /var/lib/mysql datadir = /var/lib/mysql

View File

@@ -2,6 +2,10 @@
# inception modifications : # inception modifications :
# #
# [mysqld] : # [mysqld] :
# < socket=/run/mysqld/mysqld.sock
# >
#
# [mysqld] :
# < skip-networking = false # < skip-networking = false
# > skip-networking # > skip-networking
# --- # ---
@@ -11,7 +15,7 @@
# < port = 3306 # < port = 3306
# > # >
# --- # ---
# < socket=/var/lib/mysql/mysql.sock # < socket=/run/mysqld/mysqld.sock
# > # >
# #
@@ -20,6 +24,7 @@
# this is read by the standalone daemon and embedded servers # this is read by the standalone daemon and embedded servers
[server] [server]
socket=/run/mysqld/mysqld.sock
# this is only for the mysqld standalone daemon # this is only for the mysqld standalone daemon
[mysqld] [mysqld]
@@ -28,6 +33,10 @@ datadir = /var/lib/mysql
port = 3306 port = 3306
socket=/run/mysqld/mysqld.sock socket=/run/mysqld/mysqld.sock
# sock was in : /run/mysqld/mysqld.sock
# mariadb thought it was in : /var/lib/mysql/mysql.sock
# so I made : ln -s /run/mysqld/mysqld.sock /var/lib/mysql/mysql.sock
# Galera-related settings # Galera-related settings
[galera] [galera]
# Mandatory settings # Mandatory settings

View File

@@ -1,39 +1,43 @@
# debian (~ 180s) -------------------------------------------- # debian (~ 180s) --------------------------------------------
# FROM debian:buster FROM debian:buster
#
# # vim for debug # vim for debug
# RUN apt update && apt install -y \ RUN apt update && apt install -y \
# nginx openssl \ nginx openssl \
# vim \ vim \
# && \ && \
# rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
#
# # nginx conf # nginx conf
# COPY ./conf/nginx.conf.debian /etc/nginx/nginx.conf COPY ./conf/nginx.conf.debian /etc/nginx/nginx.conf
# COPY ./conf/inception_nginx.conf /etc/nginx/conf.d/ COPY ./conf/inception_nginx.conf /etc/nginx/conf.d/
# alpine (~ 45s) --------------------------------------------- # alpine (~ 45s) ---------------------------------------------
FROM alpine:3.15 # FROM alpine:3.15
#
# vim and bash for debug # # vim and bash for debug
RUN apk update && apk add \ # RUN apk update && apk add \
nginx openssl \ # nginx openssl \
vim bash \ # vim bash \
&& \ # && \
rm -rf /var/cache/apk* # rm -rf /var/cache/apk*
#
# nginx conf # # nginx conf
COPY ./conf/nginx.conf.alpine /etc/nginx/nginx.conf # COPY ./conf/nginx.conf.alpine /etc/nginx/nginx.conf
COPY ./conf/inception_nginx.conf /etc/nginx/http.d/ # COPY ./conf/inception_nginx.conf /etc/nginx/http.d/
#
# create user www-data and assign it to group www-data # # create user www-data and assign it to group www-data
RUN adduser -S www-data && \ # RUN adduser -S www-data && \
adduser www-data www-data # adduser www-data www-data
#
# RUN mkdir -p /var/www/html
# common ----------------------------------------------------- # common -----------------------------------------------------
RUN rm -rf /var/www/html/*
# personalized index.html # personalized index.html
COPY ./conf/index.html /data/www/ COPY ./conf/index.html /data/www/

View File

@@ -1,12 +1,12 @@
# doc : https://nginx.org/en/docs/dirindex.html # doc : https://nginx.org/en/docs/dirindex.html
# WIP redirect http to https # WIP redirect http to https
server { #server {
listen 80; # listen 80;
listen [::]:80; # listen [::]:80;
server_name _; # server_name _;
return 301 https://$host$request_uri; # return 301 https://$host$request_uri;
} #}
server { server {
listen 443 ssl; # for ipv4, on port 443, specifying that accepted connections should works in ssl mode listen 443 ssl; # for ipv4, on port 443, specifying that accepted connections should works in ssl mode
@@ -20,18 +20,15 @@ server {
location / { location / {
try_files $uri $uri/ =404; # from /etc/nginx/sites-enabled/default : First attempt to serve request as file, then as directory, then fall back to displaying a 404 try_files $uri $uri/ =404; # from /etc/nginx/sites-enabled/default : First attempt to serve request as file, then as directory, then fall back to displaying a 404
root /data/www/;
} }
# pass PHP scripts to FastCGI (PHP-FPM) server # pass PHP scripts to FastCGI (PHP-FPM) server
location ~ \.php$ { location ~ \.php$ {
try_files $uri =404;
include fastcgi_params; include fastcgi_params;
include /etc/nginx/fastcgi.conf; fastcgi_pass wordpress:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_pass wordpress:9000; fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
} }
} }

View File

@@ -1,51 +0,0 @@
# find official images : https://hub.docker.com/search
#FROM ubuntu:18.04
#FROM alpine:3.16.1
#FROM debian:buster
# basic test
# build with : sudo docker build --tag test .
# run with : sudo docker run test
# 'hello' in assembly found here : http://timelessname.com/elfbin/
FROM scratch
COPY tools/hello /
CMD [ "/hello" ]
## working
#FROM scratch
#WORKDIR /
#COPY hello /
#CMD [ "/hello" ]
## working, when WORKDIR is absent, it's default is set to "/"
#FROM scratch
#COPY hello /
#CMD [ "/hello" ]
## not working, when CMD execute in shell form, instead of exec form []
#FROM scratch
#COPY hello /
#CMD /hello
## not working, because c executable need library <unistd.h>
#FROM scratch
#COPY hello_c /
#CMD [ "/hello_c" ]
## not working, when executable is copied to ".", because WORKDIR value is not "." but "/" since we gave it a relativ path so it was build in top of the implicit absolut path "/"
#FROM scratch
#WORKDIR .
#COPY hello .
#CMD [ "hello" ]
## not working, when WORKDIR is set to the present directory and executable is not copied, because the workdir is not the present directory but a directory in the file system of docker : executable need to be copied there to function
#FROM scratch
#WORKDIR /home/simplonco/Desktop/42/14_inception/inception/srcs/requirements/mariadb
#CMD [ "hello" ]
## working, because "hello" is copied to "/" and execute from "/"
#FROM scratch
#WORKDIR .
#COPY hello /
#CMD [ "/hello" ]

Binary file not shown.

View File

@@ -1,16 +0,0 @@
SECTION .data
msg: db "Hi World",10
len: equ $-msg
SECTION .text
global main
main:
mov edx,len
mov ecx,msg
mov ebx,1
mov eax,4
int 0x80
mov ebx,0
mov eax,1
int 0x80

View File

@@ -1,50 +1,50 @@
# debian ----------------------------------------------------- # debian -----------------------------------------------------
# FROM debian:buster FROM debian:buster
#
# # bash and vim for debug
# RUN apt update && apt install -y \
# php7.3 \
# php7.3-fpm \
# php7.3-mysqli \
# curl \
# bash vim
# RUN rm -rf /var/lib/apt/lists/*
#
# # fpm config
# COPY ./conf/www.conf /etc/php/7.3/fpm/pool.d/
# RUN mkdir /run/php/
#
# ENV PHP_VERSION="php-fpm7.3"
# alpine -----------------------------------------------------
FROM alpine:3.15
# bash and vim for debug # bash and vim for debug
RUN apk update && apk add \ RUN apt update && apt install -y \
php7 \ php7.3 \
php7-fpm \ php7.3-fpm \
php7-mysqli \ php7.3-mysqli \
php7-phar \
php7-json \
curl \ curl \
bash vim bash vim
RUN rm -rf /var/lib/apt/lists/* RUN rm -rf /var/lib/apt/lists/*
# fpm config # fpm config
COPY ./conf/www.conf /etc/php7/php-fpm.d/ COPY ./conf/www.conf /etc/php/7.3/fpm/pool.d/
RUN mkdir /run/php/ RUN mkdir /run/php/
# create wp directory ENV PHP_VERSION="php-fpm7.3"
ARG WP_DIR
RUN mkdir -p ${WP_DIR}
# create www-data user and add to group # alpine -----------------------------------------------------
RUN adduser -S www-data && \
adduser www-data www-data
ENV PHP_VERSION="php-fpm7" # FROM alpine:3.15
#
# # bash and vim for debug
# RUN apk update && apk add \
# php7 \
# php7-fpm \
# php7-mysqli \
# php7-phar \
# php7-json \
# curl \
# bash vim
# RUN rm -rf /var/lib/apt/lists/*
#
# # fpm config
# COPY ./conf/www.conf /etc/php7/php-fpm.d/
# RUN mkdir /run/php/
#
# # create wp directory
# ARG WP_DIR
# RUN mkdir -p ${WP_DIR}
#
# # create www-data user and add to group
# RUN adduser -S www-data && \
# adduser www-data www-data
#
# ENV PHP_VERSION="php-fpm7"
# common ----------------------------------------------------- # common -----------------------------------------------------

View File

@@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
## install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/ # install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/
mkdir -p ${WP_DIR} mkdir -p ${WP_DIR}
wp core download --path="${WP_DIR}" --allow-root wp core download --path="${WP_DIR}" --allow-root
## create config file : # create config file :
wp config create \ wp config create \
--dbhost=mariadb \ --dbhost=mariadb \
--dbname="${DB_NAME}" \ --dbname="${DB_NAME}" \
@@ -12,7 +12,7 @@ wp config create \
--dbpass="${DB_PASS}" \ --dbpass="${DB_PASS}" \
--path="${WP_DIR}" --allow-root --path="${WP_DIR}" --allow-root
## install wordpress : # install wordpress :
wp core install \ wp core install \
--url="${WP_URL}" \ --url="${WP_URL}" \
--title="${WP_TITLE}" \ --title="${WP_TITLE}" \
@@ -22,11 +22,13 @@ wp core install \
--skip-email \ --skip-email \
--path="${WP_DIR}" --allow-root --path="${WP_DIR}" --allow-root
## create user : # create user :
wp user create \ wp user create \
"${WP_USER}" "${WP_USER_EMAIL}" \ "${WP_USER}" "${WP_USER_EMAIL}" \
--user_pass="${WP_USER_PSWD}" \ --user_pass="${WP_USER_PSWD}" \
--path="${WP_DIR}" --allow-root --path="${WP_DIR}" --allow-root
# change owner and permissions to wp files
chown -R www-data:www-data /var/www/* chown -R www-data:www-data /var/www/*
chmod 755 -R /var/www/* chmod 755 -R /var/www/*