Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryangr0 committed Jun 9, 2024
1 parent 7365477 commit 81becd1
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-elasticsearch-7-17-19.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: build-elasticsearch-7-17-19
on:
push:
paths:
- Dockerfile.base
- .github/workflows/build-elasticsearch-7-17-19.yml
- images/elasticsearch/7.17.19/**
branches:
- feature/webgrip
workflow_dispatch:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/build-nginx-1-18.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: build-nginx-1-18

on: workflow_dispatch
on:
push:
paths:
- .github/workflows/build-nginx-1-18.yml
- images/nginx/1.18/**
branches:
- feature/webgrip
workflow_dispatch:

jobs:
nginx-1-18:
Expand Down
79 changes: 46 additions & 33 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ services:
image: webgrip/magento-nginx:1.18
labels:
- "traefik.enable=true"
- "traefik.http.routers.your-service.rule=Host(`docker-magento.test`)"
- "traefik.http.routers.your-service.entrypoints=websecure"
- "traefik.http.routers.your-service.tls.certresolver=myresolver"
- "traefik.http.routers.nginx.rule=Host(`docker-magento.test`)"
- "traefik.http.routers.nginx.entrypoints=websecure"
- "traefik.http.routers.nginx.tls=true"
- "traefik.http.routers.nginx.service=nginx"
# - "traefik.http.routers.docker-magento.tls.certresolver=myresolver"
ports:
- "80:8000"
- "443:8443"
- "8081:8000"
- "8443:8443"
depends_on:
- php-fpm
volumes: &appvolumes
Expand All @@ -29,8 +31,11 @@ services:
# - ~/.ssh/id_ed25519:/var/www/.ssh/id_ed25519:cached
# - ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- ./src:/var/www/html
- ./images/nginx/1.18/conf/default.development.conf:/etc/nginx/conf.d/default.conf
- ./images/nginx/1.18/conf/nginx.development.conf:/etc/nginx/nginx.conf
# - appdata:/var/www/html
# - sockdata:/sock
# - /var/run/docker.sock:/sock/docker.sock
- sockdata:/sock
# - ssldata:/etc/nginx/certs
#extra_hosts: &appextrahosts
## Selenium support, replace "magento.test" with URL of your site
Expand All @@ -45,10 +50,19 @@ services:
- 9003
volumes:
- ./src:/var/www/html:rw
- sockdata:/sock
# - ./docker-compose/php-fpm/php.ini:/usr/local/etc/php/php.ini
# - ./docker-compose/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
# - ./docker-compose/php-fpm/opcache.ini:/usr/local/etc/php/conf.d/opcache.ini
# - ./docker-compose/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.d/zzz_custom.conf
# - ./docker-compose/php-fpm/www.conf:/usr/local/etc/php-fpm.d/www.conf
# - ./docker-compose/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.d/zzz_custom.conf
# - ./docker-compose/php-fpm/www.conf:/usr/local/etc/php-fpm.d/www.conf
# - ./docker-compose/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.d/zzz_custom.conf
depends_on:
- mysql
- redis
- opensearch
- elasticsearch
environment:
PHP_IDE_CONFIG: "serverName=localhost"
#extra_hosts: *appextrahosts
Expand Down Expand Up @@ -78,28 +92,28 @@ services:
# volumes:
# - dbdata:/var/lib/mysql

opensearch:
image: webgrip/magento-opensearch:2.5
build:
context: ./images/opensearch/2.5
dockerfile: Dockerfile
ports:
- "9200:9200"
- "9300:9300"
volumes:
- opensearch-data:/usr/share/elasticsearch/data
environment:
ES_JAVA_OPTS: "-Xms2048m -Xmx2048m -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -Xss1m"
OPENSEARCH_JAVA_OPTS: "-Xms2048m -Xmx2048m"
discovery.type: single-node
cluster.routing.allocation.disk.threshold_enabled: false
script.painless.regex.enabled: true
bootstrap.memory_lock: true
network.host: 0.0.0.0
cluster.name: opensearch-cluster
node.name: opensearch-node1
index.blocks.read_only_allow_delete: true
# max_map_count: 262144 ## Uncomment the following line to increase the virtual memory map count
# opensearch:
# image: webgrip/magento-opensearch:2.5
# build:
# context: ./images/opensearch/2.5
# dockerfile: Dockerfile
# ports:
# - "9200:9200"
# - "9300:9300"
# volumes:
# - opensearch-data:/usr/share/elasticsearch/data
# environment:
# ES_JAVA_OPTS: "-Xms2048m -Xmx2048m -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -Xss1m"
# OPENSEARCH_JAVA_OPTS: "-Xms2048m -Xmx2048m"
# discovery.type: single-node
# cluster.routing.allocation.disk.threshold_enabled: false
# script.painless.regex.enabled: true
# bootstrap.memory_lock: true
# network.host: 0.0.0.0
# cluster.name: opensearch-cluster
# node.name: opensearch-node1
# index.blocks.read_only_allow_delete: true
# # max_map_count: 262144 ## Uncomment the following line to increase the virtual memory map count

redis:
image: redis:7.0-alpine
Expand Down Expand Up @@ -168,20 +182,19 @@ services:


varnish:
image: webgrip/mmagento-varnish:7.5.0-alpine
image: webgrip/magento-varnish:7.5.0-alpine
container_name: varnish
build:
context: ./images/varnish/7.5.0-alpine
dockerfile: Dockerfile
ports:
- "6081:6081"
volumes:
- ./default.vcl:/etc/varnish/default.vcl:ro
depends_on:
- nginx
volumes:
- ./images/varnish/7.5.0-alpine/default.vcl:/etc/varnish/default.vcl
tmpfs:
- /var/lib/varnish:exec # Optional: Use tmpfs for Varnish storage to increase cache responsiveness
command: "-p default_keep=300"
environment:
- VARNISH_SIZE=2G

Expand Down
4 changes: 2 additions & 2 deletions images/nginx/1.18/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apk add --no-cache openssl && \
# Production-ready configuration
FROM base AS production
COPY ./conf/nginx.production.conf /etc/nginx/nginx.conf
COPY ./conf/default.production.conf /etc/nginx/conf.d/
COPY ./conf/default.production.conf /etc/nginx/conf.d/default.conf
EXPOSE 443
USER "${APP_USER}":"${APP_GROUP}"
VOLUME /var/www
Expand All @@ -49,7 +49,7 @@ COPY --from=mkcert-installer /usr/local/share/ca-certificates/mkcert /usr/local/

# Copy development-specific Nginx configuration
COPY ./conf/nginx.development.conf /etc/nginx/nginx.conf
COPY ./conf/default.development.conf /etc/nginx/conf.d/
COPY ./conf/default.development.conf /etc/nginx/conf.d/default.conf

EXPOSE 443
USER "${APP_USER}":"${APP_GROUP}"
Expand Down
10 changes: 5 additions & 5 deletions images/nginx/1.18/conf/nginx.production.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ http {
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

log_format error
'$remote_addr - $remote_user [$time_local] "$request" '
'$status "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$request_body" "$request_body_file"';
log_format error
'$remote_addr - $remote_user [$time_local] "$request" '
'$status "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$request_body" "$request_body_file"';

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
Expand Down
6 changes: 5 additions & 1 deletion images/varnish/7.5.0-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ COPY ./default.vcl /etc/varnish/default.vcl
# Expose port 6081 for Varnish HTTP traffic
EXPOSE 6081

# Create a non-root user and switch to it
RUN addgroup -S varnish && adduser -S varnish -G varnish
USER varnish

# Start Varnish daemon with specified storage, configuration file, and run it in foreground
CMD ["varnishd", "-F", "-f", "/etc/varnish/default.vcl", "-s", "malloc,256M"]
CMD ["varnishd", "-F", "-f", "/etc/varnish/default.vcl", "-s", "malloc,256M", "-p", "default_ttl=3600", "-p", "default_grace=3600", "-a", ":6081", "-n", "/var/cache/varnish"]
29 changes: 11 additions & 18 deletions images/varnish/7.5.0-alpine/default.vcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Very advanced implementation of default.vcl for a magento production server


vcl 4.1;

import std;
Expand Down Expand Up @@ -53,30 +52,24 @@ sub vcl_backend_response {
if (bereq.http.cookie ~ "PHPSESSID") {
unset beresp.http.set-cookie;
}
}

sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
}
else {
set resp.http.X-Cache = "MISS";
}
}

sub vcl_backend_response {
# Cache images and AVIF files
if (bereq.url ~ "\.(jpeg|jpg|png|gif|ico|svg|avif)$") {
set beresp.ttl = 1w; # Cache for 1 week
set beresp.http.Cache-Control = "public, max-age=604800"; # 1 week in seconds
}

# Existing code...
if (bereq.http.cookie ~ "PHPSESSID") {
unset beresp.http.set-cookie;
# Strip all cookies except the essentials
if (bereq.http.cookie) {
set bereq.http.cookie = regsuball(bereq.http.cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");
}
}
# Not sure about this
if (bereq.http.cookie) {
set bereq.http.cookie = regsuball(bereq.http.cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", ""); // Strip all cookies except the essentials

sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
}
else {
set resp.http.X-Cache = "MISS";
}
}

0 comments on commit 81becd1

Please sign in to comment.