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 1eefdf5
Show file tree
Hide file tree
Showing 4 changed files with 25 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
14 changes: 14 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: false
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 All @@ -28,6 +36,12 @@ api_platform:
scopes:
openid: (required) Indicates that the application intends to use OIDC to verify the user's identity

when@prod:
api_platform:
http_cache:
invalidation:
enabled: true

services:
app.filter.review.admin.search:
class: 'ApiPlatform\Doctrine\Orm\Filter\SearchFilter'
Expand Down
8 changes: 8 additions & 0 deletions api/docker/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
# Debug
{$CADDY_DEBUG}
order cache before rewrite
cache {
api {
souin
}
}
}

{$SERVER_NAME}

log

cache

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

Expand Down

0 comments on commit 1eefdf5

Please sign in to comment.