{"id":24438756,"url":"https://github.com/ezeparziale/nextjs-k8s","last_synced_at":"2025-04-06T01:06:19.631Z","repository":{"id":208107970,"uuid":"720830602","full_name":"ezeparziale/nextjs-k8s","owner":"ezeparziale","description":":whale: Next.js app with 2 pods sharing cache on redis","archived":false,"fork":false,"pushed_at":"2025-03-24T20:16:22.000Z","size":569,"stargazers_count":135,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T00:05:39.276Z","etag":null,"topics":["cache","docker","docker-compose","kubernetes","nextjs","pod","redis","standalone","vps"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ezeparziale.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-19T18:20:12.000Z","updated_at":"2025-03-24T20:15:56.000Z","dependencies_parsed_at":"2023-11-19T19:31:05.068Z","dependency_job_id":"130d477f-a3b0-494c-b4d9-bc5384e72921","html_url":"https://github.com/ezeparziale/nextjs-k8s","commit_stats":null,"previous_names":["ezeparziale/nextjs_k8s"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezeparziale%2Fnextjs-k8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezeparziale%2Fnextjs-k8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezeparziale%2Fnextjs-k8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezeparziale%2Fnextjs-k8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezeparziale","download_url":"https://codeload.github.com/ezeparziale/nextjs-k8s/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419859,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","docker","docker-compose","kubernetes","nextjs","pod","redis","standalone","vps"],"created_at":"2025-01-20T19:17:39.561Z","updated_at":"2025-04-06T01:06:19.605Z","avatar_url":"https://github.com/ezeparziale.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :zap: Next.js 14 + Redis cache + Kubernetes\n\nNext.js web application with 2 pods sharing cache on Redis.\n\n## :speech_balloon: About this repo\n\n### :whale: Docker\n\nI created the Docker image following the example in:\n\n```http\nhttps://github.com/vercel/next.js/tree/canary/examples/with-docker\n```\n\nI configured the `output: \"standalone\"` property in `next-config.mjs`.\n\nMore info at:\n\n```http\nhttps://nextjs.org/docs/app/building-your-application/deploying#docker-image\n```\n\n### :card_file_box: Cache\n\nI use `Redis` to cache values and ensure consistency across all pods.\n\nI installed `@neshca/cache-handler` using `npm i -D @neshca/cache-handler`:\n\n```http\nhttps://caching-tools.github.io/next-shared-cache\n```\n\nI added `cache-handler.mjs` and configured the `cacheHandler` property in\n`next.config.mjs`.\n\nI followed this example and the same pages to validate the cache using `revalidateTag`\nand `revalidatePath`:\n\n```http\nhttps://github.com/vercel/next.js/tree/canary/examples/cache-handler-redis\n```\n\nMore info at:\n\n```http\nhttps://nextjs.org/docs/app/building-your-application/deploying#caching-and-isr\n```\n\n### :camera_flash: Image optimization\n\nI installed `sharp` using `npm install sharp`.\n\nMore info at:\n\n```http\nhttps://nextjs.org/docs/app/building-your-application/deploying#image-optimization\n```\n\n### :whale2: Kubernetes\n\nIn the `k8s` folder, there are all the `Kubernetes` manifests to create two pods with\nthe Next.js web application and one pod with a Redis server.\n\n## :runner: Run\n\n### :1st_place_medal: Option 1\n\nRun in dev mode with `npm run dev`.\n\n### :2nd_place_medal: Option 2\n\nRun in Docker using Docker Compose with\n`docker compose -f \"compose.yaml\" up -d --build`.\n\n### :3rd_place_medal: Option 3\n\nRun in Kubernetes:\n\n1. Execute `docker build -t nextjs-docker .` to create the Docker image.\n2. Execute `kubectl apply -f k8s/configmaps/nextjs.yaml`.\n3. Execute `kubectl apply -f k8s/deployments/nextjs.yaml`.\n4. Execute `kubectl apply -f k8s/deployments/redis.yaml`.\n5. Execute `kubectl apply -f k8s/services/nextjs.yaml`.\n6. Execute `kubectl apply -f k8s/services/redis.yaml`.\n7. Access `http://localhost:3000`.\n\n\u003e [!NOTE]  \n\u003e You can use this option to deploy your Docker image on your VPS.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezeparziale%2Fnextjs-k8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezeparziale%2Fnextjs-k8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezeparziale%2Fnextjs-k8s/lists"}