diff --git a/images/shopware-nginx/Dockerfile b/images/shopware-nginx/Dockerfile deleted file mode 100644 index 24eef79..0000000 --- a/images/shopware-nginx/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM nginx:1-alpine - -# Copy nginx config -COPY ./etc/nginx/templates/* /etc/nginx/templates/ diff --git a/images/shopware/.env.template b/images/shopware/.env.template index 990da33..905c6b0 100644 --- a/images/shopware/.env.template +++ b/images/shopware/.env.template @@ -7,6 +7,11 @@ COMPOSE_PROFILES= API_KEY_MYPARCELNL= API_KEY_MYPARCELBE= +### +# Set to 0 if you have a separate nginx container in your setup, to 1 to include nginx in this container. +### +WITH_NGINX=0 + # Fill in these variables to be able to use the blackfire service. You can find # these keys at https://blackfire.io/my/settings/credentials BLACKFIRE_CLIENT_ID= diff --git a/images/shopware/Dockerfile b/images/shopware/Dockerfile index 9da42c4..6e7f24f 100644 --- a/images/shopware/Dockerfile +++ b/images/shopware/Dockerfile @@ -17,6 +17,8 @@ WORKDIR ${ROOT_DIR} RUN apk upgrade && \ # Add dependencies apk add --no-cache \ + # To run in AWS \ + nginx \ # ext-gd freetype-dev \ libjpeg-turbo-dev \ @@ -35,7 +37,17 @@ RUN apk upgrade && \ # For building assets "nodejs>${NODE_VERSION}" \ npm \ - "$PHPIZE_DEPS" \ + # $PHPIZE_DEPS: + autoconf \ + dpkg-dev \ + dpkg \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c \ && \ docker-php-ext-configure gd \ --with-jpeg \ @@ -107,10 +119,10 @@ RUN apk add --no-cache \ zsh COPY ./config/.psh.yaml.override.template /tmp/.psh.yaml.override.template -COPY ./config/nginx /etc/nginx COPY ./config/php /usr/local/etc/php COPY ./config/root . COPY ./scripts /tmp/scripts +COPY ./etc/nginx/http.d /etc/nginx/http.d ENV YARN_VERSION=${YARN_VERSION} ENV SW_VERSION=${SW_VERSION} diff --git a/images/shopware/config/nginx/templates/default.conf.template b/images/shopware/config/nginx/templates/default.conf.template deleted file mode 100644 index 14feed8..0000000 --- a/images/shopware/config/nginx/templates/default.conf.template +++ /dev/null @@ -1,72 +0,0 @@ - -server { - set $site_url "${BASE_URL}"; - set $root_dir "${PROJECT_ROOT}"; - - listen 80; - - # Handle / to index.php - index index.php; - - # Our server name - server_name $server_name; - - # Where the code is located - root $root_dir/public; - - # Redirect to https - add_header Content-Security-Policy upgrade-insecure-requests; - - # Needed for Shopware install / update - location /recovery/install { - index index.php; - try_files $uri /recovery/install/index.php$is_args$args; - } - - location /recovery/update/ { - if (!-e $request_filename){ - rewrite .. /recovery/update/index.php last; - } - } - - location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|svg|webp|html|woff|woff2|xml)$ { - expires 1y; - add_header Cache-Control "public, must-revalidate, proxy-revalidate"; - - access_log off; - - # The directive enables or disables messages in error_log about files not found on disk. - log_not_found off; - - tcp_nodelay off; - - ## Set the OS file cache. - open_file_cache max=3000 inactive=120s; - open_file_cache_valid 45s; - open_file_cache_min_uses 2; - open_file_cache_errors off; - } - - location ~* ^.+\.svg$ { - add_header Content-Security-Policy "script-src 'none'"; - } - - # Forward any not found file to index.php. Also allows to have beautiful urls like /homemade-products/ - location / { - try_files $uri /index.php$is_args$args; - } - - # Let php-fpm handle .php files - location ~ \.php$ { - fastcgi_pass php:9000; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - include fastcgi.conf; - fastcgi_param HTTP_PROXY ""; - fastcgi_param HTTPS "on"; - fastcgi_buffers 8 16k; - fastcgi_buffer_size 32k; - fastcgi_read_timeout 300s; - client_body_buffer_size 128k; - http2_push_preload on; - } -} diff --git a/images/shopware-nginx/etc/nginx/templates/default.conf.template b/images/shopware/etc/nginx/http.d/default.conf similarity index 81% rename from images/shopware-nginx/etc/nginx/templates/default.conf.template rename to images/shopware/etc/nginx/http.d/default.conf index 14feed8..5d47915 100644 --- a/images/shopware-nginx/etc/nginx/templates/default.conf.template +++ b/images/shopware/etc/nginx/http.d/default.conf @@ -1,22 +1,9 @@ server { - set $site_url "${BASE_URL}"; - set $root_dir "${PROJECT_ROOT}"; + root /var/www/html; - listen 80; - - # Handle / to index.php index index.php; - # Our server name - server_name $server_name; - - # Where the code is located - root $root_dir/public; - - # Redirect to https - add_header Content-Security-Policy upgrade-insecure-requests; - # Needed for Shopware install / update location /recovery/install { index index.php; @@ -58,7 +45,7 @@ server { # Let php-fpm handle .php files location ~ \.php$ { - fastcgi_pass php:9000; + fastcgi_pass localhost:9000; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi.conf; fastcgi_param HTTP_PROXY ""; diff --git a/images/shopware/scripts/_add-preset-data.sh b/images/shopware/scripts/_add-preset-data.sh old mode 100644 new mode 100755 diff --git a/images/shopware/scripts/_build.sh b/images/shopware/scripts/_build.sh old mode 100644 new mode 100755 diff --git a/images/shopware/scripts/_cache.sh b/images/shopware/scripts/_cache.sh old mode 100644 new mode 100755 diff --git a/images/shopware/scripts/_helpers.sh b/images/shopware/scripts/_helpers.sh index 47b5da9..31e78f1 100755 --- a/images/shopware/scripts/_helpers.sh +++ b/images/shopware/scripts/_helpers.sh @@ -32,11 +32,9 @@ link-paths() { # Ignore if path is not a directory. [ -d "${path}" ] || continue - # Overwrite existing symlinks. - unlink "$dest_path" 2> /dev/null h2 "Linking $path => $dest_path" - ln -sf "$path" "$dest_path" + ln -snf "$path" "$dest_path" done else h2 "No folders found in $source_dir" diff --git a/images/shopware/scripts/_start-nginx.sh b/images/shopware/scripts/_start-nginx.sh new file mode 100755 index 0000000..f41065a --- /dev/null +++ b/images/shopware/scripts/_start-nginx.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +start-nginx() { + h1 "Starting nginx..." + + if pidof -s nginx > /dev/null; then + h2 "nginx is already running" + return + fi + + nginx; + + if [ "$?" -eq 0 ]; then + h2 "Started nginx." + else + h2 "Failed to start nginx." + exit 1 + fi +} \ No newline at end of file diff --git a/images/shopware/scripts/_wait-for-deps.sh b/images/shopware/scripts/_wait-for-deps.sh old mode 100644 new mode 100755 diff --git a/images/shopware/scripts/entrypoint.sh b/images/shopware/scripts/entrypoint.sh index df01d3d..853b60e 100755 --- a/images/shopware/scripts/entrypoint.sh +++ b/images/shopware/scripts/entrypoint.sh @@ -24,5 +24,9 @@ fi reset-permissions +if [ "${WITH_NGINX}" -eq 1 ]; then + start-nginx +fi + h1 "🔵 Shopware is ready at ${FULL_URL}/admin ✨" tail -f var/log/*.log & wait