Skip to content

Commit

Permalink
feat: add Souin
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Aug 23, 2023
1 parent ae6daab commit c8dba7e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
TRUSTED_HOSTS=^(localhost|caddy)$
OIDC_SERVER_URL=https://localhost/oidc/realms/demo
OIDC_SWAGGER_CLIENT_ID=api-platform-swagger
# The api url that is called to invalidate cached resources
SOUIN_API_URL=http://caddy/souin-api/souin

###> symfony/framework-bundle ###
APP_ENV=dev
Expand Down
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ARG TARGETARCH
WORKDIR /srv/app

# Download Caddy compiled with the Mercure and Vulcain modules
ADD --chmod=500 https://caddyserver.com/api/download?os=linux&arch=$TARGETARCH&p=github.com/dunglas/mercure/caddy&p=github.com/dunglas/vulcain/caddy /usr/bin/caddy
ADD --chmod=500 https://caddyserver.com/api/download?os=linux&arch=$TARGETARCH&p=github.com/dunglas/mercure/caddy&p=github.com/dunglas/vulcain/caddy&p=github.com/caddyserver/cache-handler /usr/bin/caddy

COPY --link docker/caddy/Caddyfile /etc/caddy/Caddyfile

Expand Down
8 changes: 8 additions & 0 deletions api/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ api_platform:
graphql:
graphql_playground: false
mercure: ~
http_cache:
public: true
invalidation:
enabled: true
purger: 'api_platform.http_cache.purger.souin'
urls: ['%env(SOUIN_API_URL)%']
defaults:
stateless: true
cache_headers:
max_age: 0
shared_max_age: 3600
vary: ['Content-Type', 'Authorization', 'Origin']
extra_properties:
standard_put: true
Expand Down
4 changes: 4 additions & 0 deletions api/docker/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
# Debug
{$CADDY_DEBUG}
order cache before rewrite
cache
}

{$SERVER_NAME}

log

cache

# Matches requests for OIDC routes
@oidc expression path('/oidc/*')

Expand Down

0 comments on commit c8dba7e

Please sign in to comment.