Skip to content

k8s nextjs deployment#378

Merged
josvandervelde merged 18 commits into
openml:masterfrom
HelderMendes:feat/k8s-nextjs-deployment
Mar 7, 2026
Merged

k8s nextjs deployment#378
josvandervelde merged 18 commits into
openml:masterfrom
HelderMendes:feat/k8s-nextjs-deployment

Conversation

@HelderMendes

Copy link
Copy Markdown
Contributor
  • Add Kubernetes manifests for Next.js frontend (dev, test, prod environments)
  • Add single-image Docker deployment with runtime configuration
  • Update next.config.ts for standalone output with Docker
  • Update app-next/src/lib/config.ts and api.ts for runtime env support

Changes

  • k8s/ — Kubernetes deployments, configmaps, secrets for all environments
  • app-next/Dockerfile — multi-stage standalone build
  • app-next/docker-compose.yml — local Docker setup
  • app-next/next.config.ts — standalone output mode

Test plan

  • Docker build succeeds: docker build -t openml-next ./app-next
  • Container runs with env vars injected at runtime
  • k8s manifests apply cleanly to dev namespace

Helder Mendes and others added 6 commits February 26, 2026 22:42
…nment setup

- Update docker/entrypoint.sh to support ENVIRONMENT variable
  - development: 1 worker, debug logs, reload enabled
  - production: 4 workers, warning logs, optimized
  - default: legacy mode (backward compatible)

- Add k8s/ directory with complete deployment setup:
  - dev/: Development configs (1 replica, SQLite, test server)
  - prod/: Production configs (3-10 replicas, MySQL, HPA, autoscaling)
  - Separate ConfigMaps and Secrets for each environment
  - Complete README with deployment instructions
  - Test script for validating container behavior

- Add STATS_API_ARCHITECTURE.md documenting the stats API flow

Benefits:
- Single Docker image for all environments
- Environment-specific behavior via runtime config
- No production impact until manually deployed
- Zero downtime deployments with rolling updates
- Ready for team review and staging testing

Co-Authored-By: Claude <noreply@anthropic.com>
Clean up documentation files and finalize K8s configuration
Replace build-time NEXT_PUBLIC_* baking with runtime injection via
window.__ENV__. A single Docker image now works across all environments
(dev, staging, prod) by injecting variables at container startup.

- layout.tsx: inject process.env vars as window.__ENV__ via <script>
- config.ts: new getConfig() helper (reads window.__ENV__ client-side,
  process.env server-side)
- api.ts, elasticsearch.ts, likes.ts: switch to getConfig()
- next.config.ts: expose required server-side env vars
- Dockerfile: remove build ARGs, keep runtime ENV declarations
- docker-compose.yml: remove build.args, use env_file (.env.local),
  fix SMTP variable names (SMTP_HOST/SMTP_USER)
- .gitignore: add .docker.run (local secrets reference file)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add dev and prod K8s deployment files for the openml/frontend image.
The image is published via GitHub Actions without build args, relying
on runtime env injection (see previous commit).

dev/ (openml-dev namespace):
- nextjs-configmap.yaml: non-secret vars (URLs, NEXTAUTH_URL, RP_ID…)
- nextjs-secrets.yaml: placeholder secrets for local cluster testing
- nextjs-deployment.yaml: 1 replica, imagePullPolicy: Always

prod/ (openml-prod namespace):
- nextjs-configmap.yaml: production URLs (www.openml.org)
- nextjs-secrets.yaml.template: safe-to-commit template with CHANGE-ME
  placeholders + kubectl and External Secrets Operator examples
- nextjs-deployment.yaml: 3 replicas, rolling update (maxUnavailable:0),
  pod anti-affinity, health probes, HPA (min 3 / max 10)

SINGLE_IMAGE_NEXTJS_DEPLOYMENT.md: full deployment guide for the team

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@HelderMendes

Copy link
Copy Markdown
Contributor Author

Part of the app-next-v3 feature branch work — splitting changes into focused PRs for easier review.

@josvandervelde josvandervelde left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for this separate PR. This makes reviewing a lot easier!

I like the overal direction. I could not get it to work though - please let me know if this is a problem of my setup. Moreover, I think some files should be changed to move from process.env to the new getConfig. Could you take a look at this?

[Edit]: I did get it to build using TUe VPN. It seems to run fine, also with switching from openml.org to test.openml.org with the same docker image. So I'm happy with that!

Comment thread k8s/SINGLE_IMAGE_NEXTJS_DEPLOYMENT.md Outdated
Comment thread app-next/Dockerfile
Comment thread app-next/Dockerfile
Comment thread app-next/next.config.ts Outdated
Comment thread app-next/docker-compose.yml
Comment thread app-next/docker-compose.yml Outdated
Comment thread app-next/docker-compose.yml
Comment thread app-next/docker-compose.yml Outdated
Comment thread app-next/docker-compose.yml
Comment thread app-next/docker-compose.yml

@josvandervelde josvandervelde left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the current state! I don't think overriding the environment variable using .env.local work. When I specify, for instance, another NEXT_PUBLIC_OPENML_URL in env.local, it does not change. For me this is no problem though - we can set the variables directly in docker-compose.yaml.

@joaquinvanschoren joaquinvanschoren self-requested a review March 6, 2026 10:39
@josvandervelde josvandervelde merged commit 2a445c7 into openml:master Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants