From f93b632ef56e639180d992231cbd35a1590ba9e2 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 17 Feb 2021 16:44:22 +0100 Subject: [PATCH 1/7] correct nginx config --- Dockerfile | 30 ++++---- config/nginx/fastcgi.conf | 25 +++++++ config/nginx/mime.types | 88 +++++++++++++++++++++++ config/nginx/nginx.conf | 142 +++++++++++++++++++++++--------------- 4 files changed, 214 insertions(+), 71 deletions(-) create mode 100644 config/nginx/fastcgi.conf create mode 100644 config/nginx/mime.types diff --git a/Dockerfile b/Dockerfile index f285442fc..11ac3863a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,17 @@ -FROM nginx - -# install php fpm -RUN apt-get update \ - && apt-get -y --no-install-recommends install curl unzip php7.3-curl php7.3-fpm php7.3-mbstring php7.3-intl php7.3-xml php7.3-pdo php7.3-mysql \ - && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -# install composer -COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer - -WORKDIR /usr/share/nginx/html - -COPY . . -COPY ./config/nginx/nginx.conf /etc/nginx/sites-enabled/nginx.conf +FROM nginx + +# install php fpm +RUN apt-get update \ + && apt-get -y --no-install-recommends install curl unzip php7.3-curl php7.3-fpm php7.3-mbstring php7.3-intl php7.3-xml php7.3-pdo php7.3-mysql \ + && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +# install composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +WORKDIR /usr/share/nginx/html + +COPY . . +COPY ./config/nginx/nginx.conf /etc/nginx/conf.d/default.conf +COPY ./config/nginx/fastcgi.conf /etc/nginx/ +COPY ./config/nginx/mime.types /etc/nginx/ RUN composer update --no-scripts --no-autoloader \ No newline at end of file diff --git a/config/nginx/fastcgi.conf b/config/nginx/fastcgi.conf new file mode 100644 index 000000000..c2976fe91 --- /dev/null +++ b/config/nginx/fastcgi.conf @@ -0,0 +1,25 @@ +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_param QUERY_STRING $query_string; +fastcgi_param REQUEST_METHOD $request_method; +fastcgi_param CONTENT_TYPE $content_type; +fastcgi_param CONTENT_LENGTH $content_length; + +fastcgi_param SCRIPT_NAME $fastcgi_script_name; +fastcgi_param REQUEST_URI $request_uri; +fastcgi_param DOCUMENT_URI $document_uri; +fastcgi_param DOCUMENT_ROOT $document_root; +fastcgi_param SERVER_PROTOCOL $server_protocol; +fastcgi_param REQUEST_SCHEME $scheme; +fastcgi_param HTTPS $https if_not_empty; + +fastcgi_param GATEWAY_INTERFACE CGI/1.1; +fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + +fastcgi_param REMOTE_ADDR $remote_addr; +fastcgi_param REMOTE_PORT $remote_port; +fastcgi_param SERVER_ADDR $server_addr; +fastcgi_param SERVER_PORT $server_port; +fastcgi_param SERVER_NAME $server_name; + +# PHP only, required if PHP was built with --enable-force-cgi-redirect +fastcgi_param REDIRECT_STATUS 200; \ No newline at end of file diff --git a/config/nginx/mime.types b/config/nginx/mime.types new file mode 100644 index 000000000..84c644fc7 --- /dev/null +++ b/config/nginx/mime.types @@ -0,0 +1,88 @@ +types { + text/html html htm shtml; + text/css css; + text/xml xml; + image/gif gif; + image/jpeg jpeg jpg; + application/javascript js; + application/atom+xml atom; + application/rss+xml rss; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/png png; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + image/svg+xml svg svgz; + image/webp webp; + + application/font-woff woff; + application/java-archive jar war ear; + application/json json; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.apple.mpegurl m3u8; + application/vnd.ms-excel xls; + application/vnd.ms-fontobject eot; + application/vnd.ms-powerpoint ppt; + application/vnd.wap.wmlc wmlc; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/xspf+xml xspf; + application/zip zip; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream iso img; + application/octet-stream msi msp msm; + + application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; + application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/ogg ogg; + audio/x-m4a m4a; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mp2t ts; + video/mp4 mp4; + video/mpeg mpeg mpg; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-m4v m4v; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/config/nginx/nginx.conf b/config/nginx/nginx.conf index 190247953..8cba3fd5d 100644 --- a/config/nginx/nginx.conf +++ b/config/nginx/nginx.conf @@ -1,58 +1,86 @@ -server { - - listen 80 ; - listen [::]:80; - server_name 0.0.0.0; - - #include /etc/nginx/common/protect.conf; - #include /etc/nginx/common/protect_add_header.conf; - #include /etc/nginx/common/ssl.conf; - - - root /usr/share/nginx/html/webroot; - index index.php; - - location ~* \.(png|jpg|ico)\$ { - expires 30d; - } - - location ~* \.(js|css) { - # expires 1d; - expires 1d; - } - - location ~ \.php\$ { - include snippets/fastcgi-php.conf; - fastcgi_pass unix:/run/php/php7.3-fpm.sock; - #fastcgi_pass 127.0.0.1:9000; - - } - - location ~ /\.ht { - deny all; - } - - location /account { - proxy_http_version 1.1; - proxy_set_header Upgrade \$http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_cache_bypass \$http_upgrade; - proxy_set_header X-Real-IP \$remote_addr; - proxy_set_header X-Forwarded-For \$remote_addr; - proxy_set_header Host \$host; - rewrite /account/(.*) /\$1 break; - - #proxy_next_upstream error timeout invalid_header http_502 non_idempotent; - proxy_pass http://login-server:1200; - proxy_redirect off; - - - } - - location / { - try_files \$uri \$uri/ /index.php?\$args; - } - -# access_log /var/log/nginx/access.log main; - + +server { + + listen 80 ; + listen [::]:80; + server_name 0.0.0.0; + + #include /etc/nginx/common/protect.conf; + #include /etc/nginx/common/protect_add_header.conf; + #include /etc/nginx/common/ssl.conf; + + + root /usr/share/nginx/html/webroot; + index index.php; + + location ~* \.(png|jpg|ico|webp)\$ { + expires 30d; + } + + location ~* \.(js|css) { + # expires 1d; + expires 1d; + } + + location ~ \.php\$ { + # regex to split $uri to $fastcgi_script_name and $fastcgi_path + fastcgi_split_path_info ^(.+\.php)(/.+)$; + + # Check that the PHP script exists before passing it + try_files $fastcgi_script_name =404; + + # Bypass the fact that try_files resets $fastcgi_path_info + # see: http://trac.nginx.org/nginx/ticket/321 + set $path_info $fastcgi_path_info; + fastcgi_param PATH_INFO $path_info; + + fastcgi_index index.php; + include fastcgi.conf; + + fastcgi_pass unix:/run/php/php7.3-fpm.sock; + #fastcgi_pass 127.0.0.1:9000; + + } + + location ~ /\.ht { + deny all; + } + + location /account { + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_cache_bypass \$http_upgrade; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$remote_addr; + proxy_set_header Host \$host; + rewrite /account/(.*) /\$1 break; + + #proxy_next_upstream error timeout invalid_header http_502 non_idempotent; + proxy_pass http://login-server:1200; + proxy_redirect off; + + + } + + location /login_api { + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_cache_bypass \$http_upgrade; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$remote_addr; + proxy_set_header Host \$host; + rewrite /login_api/(.*) /\$1 break; + + proxy_pass http://login-server:1201; + proxy_redirect off; + } + + location / { + try_files \$uri \$uri/ /index.php?\$args; + } + +# access_log /var/log/nginx/access.log main; + } \ No newline at end of file From 4d2308eb8a100b8da1821b151c89a93a113b0fcc Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 17 Feb 2021 20:07:22 +0100 Subject: [PATCH 2/7] change dockerfile to able to copy app.php from configs --- Dockerfile | 17 ++++++----------- config/nginx/nginx.conf | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11ac3863a..d8b905da8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,12 @@ -FROM nginx +FROM phpdockerio/php74-fpm # install php fpm RUN apt-get update \ - && apt-get -y --no-install-recommends install curl unzip php7.3-curl php7.3-fpm php7.3-mbstring php7.3-intl php7.3-xml php7.3-pdo php7.3-mysql \ + && apt-get -y --no-install-recommends install curl unzip php7.4-curl php7.4-fpm php7.4-mbstring php7.4-intl php7.4-xml php7.4-pdo php7.4-mysql \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -# install composer -COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer -WORKDIR /usr/share/nginx/html +WORKDIR /var/www/cakephp -COPY . . -COPY ./config/nginx/nginx.conf /etc/nginx/conf.d/default.conf -COPY ./config/nginx/fastcgi.conf /etc/nginx/ -COPY ./config/nginx/mime.types /etc/nginx/ -RUN composer update --no-scripts --no-autoloader \ No newline at end of file +COPY ./community_server/ . +COPY ./configs/community_server/app.php ./config/ +RUN composer update diff --git a/config/nginx/nginx.conf b/config/nginx/nginx.conf index 8cba3fd5d..5aa5c3095 100644 --- a/config/nginx/nginx.conf +++ b/config/nginx/nginx.conf @@ -37,8 +37,8 @@ server { fastcgi_index index.php; include fastcgi.conf; - fastcgi_pass unix:/run/php/php7.3-fpm.sock; - #fastcgi_pass 127.0.0.1:9000; + #fastcgi_pass unix:/run/php/php7.3-fpm.sock; + fastcgi_pass 127.0.0.1:9000; } From 7780bdc3c6db1507c9a20d10f30aa1f046b61563 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 17 Feb 2021 20:27:22 +0100 Subject: [PATCH 3/7] create tmp and logs folder and make it accessable, normally composer script does that, but it didn't seems to work inside docker --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d8b905da8..2f3c0412a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ RUN apt-get update \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* WORKDIR /var/www/cakephp - +RUN mkdir logs && mkdir tmp && chmod 777 logs && chmod 777 tmp COPY ./community_server/ . COPY ./configs/community_server/app.php ./config/ RUN composer update + From 93667eb83250d2a7db5de3051aee76ccacd44149 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Sat, 13 Mar 2021 15:01:52 +0100 Subject: [PATCH 4/7] update submodule, fix removed link --- .gitmodules | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index f6d75c934..8499eaac6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "mithril_client"] - path = mithril_client - url = ssh://git@***REMOVED***/~/frontend/gradido_mithrilJS_client [submodule "src/protobuf"] path = src/protobuf - url = ssh://git@***REMOVED***/~/gradido_protocol + url = git@github.com:gradido/gradido_protocol.git From dea5f01561dacf9ddba8be6131454fa9e2c31702 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 13 Mar 2021 18:01:08 +0100 Subject: [PATCH 5/7] fixed gitmodule urls --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index f6d75c934..09958949c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "mithril_client"] path = mithril_client - url = ssh://git@***REMOVED***/~/frontend/gradido_mithrilJS_client + url = ssh://git@github.com:gradido/gradido_mithrilJS_client [submodule "src/protobuf"] path = src/protobuf - url = ssh://git@***REMOVED***/~/gradido_protocol + url = ssh://git@github.com:gradido/gradido_protocol.git From afca6dd0484ca198f5c4784bb1d18b436fb1ba68 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 13 Mar 2021 18:07:24 +0100 Subject: [PATCH 6/7] fixed gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 09958949c..417146e03 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "mithril_client"] path = mithril_client - url = ssh://git@github.com:gradido/gradido_mithrilJS_client + url = ssh://git@github.com:gradido/gradido_mithrilJS_client.git [submodule "src/protobuf"] path = src/protobuf url = ssh://git@github.com:gradido/gradido_protocol.git From 89d4bcf98d891a90650f8955b9960485a40b8fff Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 13 Mar 2021 18:15:45 +0100 Subject: [PATCH 7/7] remove ssh:// (maybe thats the problem) --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 417146e03..55bad9c77 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "mithril_client"] path = mithril_client - url = ssh://git@github.com:gradido/gradido_mithrilJS_client.git + url = git@github.com:gradido/gradido_mithrilJS_client.git [submodule "src/protobuf"] path = src/protobuf - url = ssh://git@github.com:gradido/gradido_protocol.git + url = git@github.com:gradido/gradido_protocol.git