Skip to content

Commit

Permalink
fix: sitemap proxied from nextjs app (#183)
Browse files Browse the repository at this point in the history
* fix: sitemap proxied from nextjs app

* fix: robots.txt to new sitemap

* fix: cpu limit

* fix: better init strapi (#192)

---------

Co-authored-by: YoanRos <[email protected]>
Co-authored-by: Matéo Mévollon <[email protected]>
Co-authored-by: Matéo Mévollon <[email protected]>
  • Loading branch information
4 people authored Jul 8, 2024
1 parent be85e5f commit ec9c454
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
33 changes: 26 additions & 7 deletions .kontinuous/env/dev/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
api:
cmd: true
args:
- sh
- -c
- "yarn strapi import --force -f seed-data.tar.gz && yarn start"
~preDeploy.cleaner:
match:
kind: Deployment
Expand All @@ -18,13 +13,37 @@ api:
# so public cannot be a volume, it must be its parent
# see https://github.com/strapi/strapi/issues/17809
initContainers:
- name: move-public-to-volume
- name: import-and-prepare
image:
"{{ .Values.global.registry }}/{{ .Values.global.projectName }}/{{
.Values.global.imageRepository }}/api:{{ .Values.global.imageTag }}"
command: ["/bin/sh", "-c"]
args:
- cp -r public/. /mnt/public;
- |
yarn strapi import --force -f seed-data.tar.gz && \
cp -r public/. /mnt/public
volumeMounts:
- name: public
mountPath: /mnt/public
envFrom:
- secretRef:
name: pg-app
- secretRef:
name: api
env:
- name: DATABASE_HOST
value: "$(PGHOST)"
- name: DATABASE_PORT
value: "$(PGPORT)"
- name: DATABASE_NAME
value: "$(PGDATABASE)"
- name: DATABASE_USERNAME
value: "$(PGUSER)"
- name: DATABASE_PASSWORD
value: "$(PGPASSWORD)"
- name: HOST
value: "0.0.0.0"
- name: PORT
value: "1337"
- name: DATABASE_CLIENT
value: postgres
2 changes: 0 additions & 2 deletions .kontinuous/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ api:
~needs: ["build-api", "pg"]
imagePackage: api
probesPath: /_health
startupProbe:
initialDelaySeconds: 300
containerPort: "1337"
envFrom:
- secretRef:
Expand Down
28 changes: 28 additions & 0 deletions next-app/app/sitemap.xml/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// sitemap/index.xml
// https://api-ozensemble-site.fabrique.social.gouv.fr/api/sitemap/index.xml
export const dynamic = "force-dynamic" // defaults to auto

export async function GET() {
const sitemap = await fetch(
"https://api-ozensemble-site.fabrique.social.gouv.fr/api/sitemap/index.xml"
).then((res) => res.text())

if (!sitemap) {
return new Response("It exists but its fucked up", {
headers: {
"Content-Type": "text/xml",
},
})
}
return new Response(
sitemap.replace(
`<?xml-stylesheet type="text/xsl" href="xsl/sitemap.xsl"?>`,
``
),
{
headers: {
"Content-Type": "text/xml",
},
}
)
}
2 changes: 1 addition & 1 deletion next-app/public/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ User-agent: *
Allow: /public/ # Allow crawling of pages in the /public/ directory
Allow: /images/ # Allow crawling of images
Disallow: /fb-redirection/
Sitemap: https://api-ozensemble-site.fabrique.social.gouv.fr/api/sitemap/index.xml
Sitemap: https://ozensemble-site.fabrique.social.gouv.fr/sitemap.xml

0 comments on commit ec9c454

Please sign in to comment.