diff --git a/compose.override.yaml b/compose.override.yaml deleted file mode 100644 index 8dc54de..0000000 --- a/compose.override.yaml +++ /dev/null @@ -1,18 +0,0 @@ - -services: -###> doctrine/doctrine-bundle ### - database: - ports: - - "5432" -###< doctrine/doctrine-bundle ### - -###> symfony/mailer ### - mailer: - image: axllent/mailpit - ports: - - "1025" - - "8025" - environment: - MP_SMTP_AUTH_ACCEPT_ANY: 1 - MP_SMTP_AUTH_ALLOW_INSECURE: 1 -###< symfony/mailer ### diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 89c74d1..0000000 --- a/compose.yaml +++ /dev/null @@ -1,25 +0,0 @@ - -services: -###> doctrine/doctrine-bundle ### - database: - image: postgres:${POSTGRES_VERSION:-16}-alpine - environment: - POSTGRES_DB: ${POSTGRES_DB:-app} - # You should definitely change the password in production - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!} - POSTGRES_USER: ${POSTGRES_USER:-app} - healthcheck: - test: ["CMD", "pg_isready", "-d", "${POSTGRES_DB:-app}", "-U", "${POSTGRES_USER:-app}"] - timeout: 5s - retries: 5 - start_period: 60s - volumes: - - database_data:/var/lib/postgresql/data:rw - # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! - # - ./docker/db/data:/var/lib/postgresql/data:rw -###< doctrine/doctrine-bundle ### - -volumes: -###> doctrine/doctrine-bundle ### - database_data: -###< doctrine/doctrine-bundle ### diff --git a/docker-compose.yaml b/docker-compose.yaml index 8c9a3bf..5cec85d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,17 +1,52 @@ services: - ukhorsecremations.co.uk-web: - container_name: ukhorsecremations.co.uk-web - build: . + ukhorsecremations.co.uk-nginx: + image: nginx:latest + container_name: ukhorsecremations.co.uk-nginx restart: unless-stopped + working_dir: /var/www labels: - traefik.enable=true - traefik.docker.network=proxy - traefik.http.routers.ukhorsecremations-co-uk.rule=Host(`ukhorsecremations-co-uk.web1.phatkoala.net`) - traefik.http.services.ukhorsecremations-co-uk.loadbalancer.server.port=3000 - traefik.http.routers.ukhorsecremations-co-uk.middlewares=basic-auth@file + volumes: + - './etc/nginx/nginx.conf:/etc/nginx/nginx.conf' + - './:/var/www' networks: - - proxy + - internal + - external + + # ukhorsecremations.co.uk-node: + # container_name: ukhorsecremations.co.uk-node + # build: + # context: . + # dockerfile: ./etc/node/Dockerfile + + ukhorsecremations.co.uk-php: + container_name: ukhorsecremations.co.uk-php + build: + context: . + dockerfile: ./etc/php/Dockerfile + args: + APP_ENV: ${APP_ENV} + restart: unless-stopped + working_dir: /var/www + env_file: + - .env + volumes: + - './etc/php/php.ini:/usr/local/etc/php/conf.d/site.ini' + - './:/var/www' + expose: + - "9000" + networks: + - internal + - external networks: - proxy: - external: true + internal: + name: "internal" + internal: true + external: + name: "external" + driver: bridge diff --git a/etc/nginx/nginx.conf b/etc/nginx/nginx.conf new file mode 100644 index 0000000..726e9d8 --- /dev/null +++ b/etc/nginx/nginx.conf @@ -0,0 +1,94 @@ +worker_processes auto; +error_log stderr warn; +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + # Define custom log format to include reponse times + log_format main_timed '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for" ' + '$request_time $upstream_response_time $pipe $upstream_cache_status'; + + access_log /dev/stdout main_timed; + error_log /dev/stderr notice; + + keepalive_timeout 65; + + # Write temporary files to /tmp so they can be created as a non-privileged user + client_body_temp_path /tmp/client_temp; + proxy_temp_path /tmp/proxy_temp_path; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + scgi_temp_path /tmp/scgi_temp; + + # Default server definition + server { + listen [::]:443 default_server; + listen 443 default_server; + server_name ukhorsecremations.co.uk; + + sendfile off; + + root /var/www/public; + index index.php index.html; + + location / { + # First attempt to serve request as file, then + # as directory, then fall back to index.php + try_files $uri $uri/ /index.php?q=$uri&$args; + } + + # Redirect server error pages to the static page /50x.html + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /var/lib/nginx/html; + } + + # Pass the PHP scripts to PHP-FPM listening on 127.0.0.1:9000 + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass ukhorsecremations.co.uk-php:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_index index.php; + include fastcgi_params; + } + + location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { + expires 5d; + } + + # Deny access to . files, for security + location ~ /\. { + log_not_found off; + deny all; + } + + # Allow fpm ping and status from localhost + location ~ ^/(fpm-status|fpm-ping)$ { + access_log off; + allow 127.0.0.1; + deny all; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + } + } + + gzip on; + gzip_proxied any; + gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss; + gzip_vary on; + gzip_disable "msie6"; + + # Include other server configs + include /etc/nginx/conf.d/*.conf; +} diff --git a/etc/node/Dockerfile b/etc/node/Dockerfile new file mode 100644 index 0000000..c9ef1b0 --- /dev/null +++ b/etc/node/Dockerfile @@ -0,0 +1,11 @@ +FROM node:12 AS node +WORKDIR /app +COPY assets/ assets/ +COPY public/wp-content/themes/phatkoala.uk/ public/wp-content/themes/phatkoala.uk/ +COPY package.json package.json +COPY postcss.config.js postcss.config.js +COPY tailwind.config.js tailwind.config.js +COPY webpack.config.js webpack.config.js +COPY yarn.lock yarn.lock +RUN yarn install --immutable +RUN yarn encore production \ No newline at end of file diff --git a/etc/php/Dockerfile b/etc/php/Dockerfile new file mode 100644 index 0000000..e2d2e16 --- /dev/null +++ b/etc/php/Dockerfile @@ -0,0 +1,39 @@ +FROM php:8.4-fpm + +# PHP Extensions +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN chmod +x /usr/local/bin/install-php-extensions && install-php-extensions \ + bcmath curl dom exif fileinfo filter hash iconv intl imagick json memcached mbstring mysqli opcache openssl pcre \ + redis simplexml xml xmlreader zlib zip + +# New Relic +#ARG NEW_RELIC_AGENT_VERSION +#ARG NEW_RELIC_LICENSE_KEY +#ARG NEW_RELIC_APPNAME +#ARG NEW_RELIC_DAEMON_ADDRESS + +#RUN curl -L "https://download.newrelic.com/php_agent/release/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.tar.gz" | tar -C /tmp -zx \ +# && export NR_INSTALL_USE_CP_NOT_LN=1 \ +# && export NR_INSTALL_SILENT=1 \ +# && /tmp/newrelic-php5-*/newrelic-install install \ +# && rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* +# +#RUN sed -i -e s/\"REPLACE_WITH_REAL_KEY\"/${NEW_RELIC_LICENSE_KEY}/ \ +# -e s/newrelic.appname[[:space:]]=[[:space:]].\*/newrelic.appname="${NEW_RELIC_APPNAME}"/ \ +# -e s/\;newrelic.daemon.address[[:space:]]=[[:space:]].\*/newrelic.daemon.address="newrelic-php-daemon:31339"/ \ +# /usr/local/etc/php/conf.d/newrelic.ini + +# Configure email sending +#RUN apt-get update && apt-get install -y zlib1g-dev libzip-dev sendmail +#RUN echo "sendmail_path=/usr/sbin/sendmail -t -i" >> /usr/local/etc/php/conf.d/sendmail.ini +#RUN sed -i '/#!\/bin\/sh/aservice sendmail restart' /usr/local/bin/docker-php-entrypoint +#RUN sed -i '/#!\/bin\/sh/aecho "$(hostname -i)\t$(hostname) $(hostname).localhost" >> /etc/hosts' /usr/local/bin/docker-php-entrypoint +#RUN rm -rf /var/lib/apt/lists/* + +# Local development +ARG APP_ENV +RUN if [ "${APP_ENV}" = "dev" ] ; then \ + cp -f "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \ + pecl install xdebug && \ + docker-php-ext-enable xdebug; \ +fi diff --git a/etc/php/php.ini b/etc/php/php.ini new file mode 100644 index 0000000..0e73294 --- /dev/null +++ b/etc/php/php.ini @@ -0,0 +1,18 @@ +[PHP] +memory_limit = 512M +display_errors = 1 +error_reporting = E_ALL + +[Date] +date.timezone="UTC" + +[xdebug] +xdebug.mode = develop,debug +xdebug.client_host = host.docker.internal +xdebug.client_port = 9003 +xdebug.discover_client_host = off +xdebug.idekey = PHPSTORM +xdebug.cli_color = 1 + +[newrelic] +newrelic.loglevel = info \ No newline at end of file