Skip to content

Commit

Permalink
feat(shopware): add nginx to container for aws environment (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen authored Nov 8, 2024
1 parent 048be40 commit 37d42e0
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 216 deletions.
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ DOCKER_CACHE_MODE=max
# TODO: Find a way to set this based on the architecture of the runner.
DOCKER_BUILD_PLATFORMS=linux/arm64

###
# Set to 0 for a separate Nginx container, to 1 to include Nginx in the platform (php) container
###
WITH_NGINX=1

# Don't try and push the image to Docker Hub.
DOCKER_PUSH=0

Expand Down
4 changes: 0 additions & 4 deletions images/shopware-nginx/Dockerfile

This file was deleted.

121 changes: 0 additions & 121 deletions images/shopware/.env.template

This file was deleted.

16 changes: 14 additions & 2 deletions images/shopware/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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}
Expand Down
72 changes: 0 additions & 72 deletions images/shopware/config/nginx/templates/default.conf.template

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@

server {
set $site_url "${BASE_URL}";
set $root_dir "${PROJECT_ROOT}";
# Shopware installs in a subdirectory /public by default
root /var/www/html/public;

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;
Expand Down
Empty file modified images/shopware/scripts/_add-preset-data.sh
100644 → 100755
Empty file.
Empty file modified images/shopware/scripts/_build.sh
100644 → 100755
Empty file.
Empty file modified images/shopware/scripts/_cache.sh
100644 → 100755
Empty file.
4 changes: 1 addition & 3 deletions images/shopware/scripts/_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 23 additions & 0 deletions images/shopware/scripts/_start-nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

start-nginx() {
h1 "Starting nginx..."

if pidof -s nginx > /dev/null; then
h2 "nginx is already running"
return
fi

# replace docker php fpm location with local one in nginx default config
sed -i -e 's|php:9000;|localhost:9000;|g' /etc/nginx/http.d/default.conf

# start nginx
nginx;

if [ "$?" -eq 0 ]; then
h2 "Started nginx."
else
h2 "Failed to start nginx."
exit 1
fi
}
Empty file modified images/shopware/scripts/_wait-for-deps.sh
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions images/shopware/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 37d42e0

Please sign in to comment.