Skip to content

feat(docker): add production image and Docker Hub publishing - #186

Merged
WhiteMuush merged 2 commits into
developfrom
feat/docker-production-image
Sep 2, 2026
Merged

feat(docker): add production image and Docker Hub publishing#186
WhiteMuush merged 2 commits into
developfrom
feat/docker-production-image

Conversation

@WhiteMuush

Copy link
Copy Markdown
Owner

Context

The repository only shipped a development image: it bind-mounts the source and runs next dev, so it cannot be distributed. This adds a production image and the workflow that publishes it to Docker Hub.

Changes

  • Dockerfile is now the production build: multi-stage (deps, Prisma CLI, Next build, runner), unprivileged node user, healthcheck on /api/health.
  • The previous development image moves to Dockerfile.dev; compose.yml points at it, so the local stack is unchanged.
  • next.config.ts emits a standalone server bundle, so the runner carries the traced runtime instead of the full node_modules.
  • docker/entrypoint.sh refuses to start without DATABASE_URL, applies prisma migrate deploy, then execs the server. RUN_MIGRATIONS=false skips the migration step when a separate job owns the schema.
  • .github/workflows/docker-publish.yml builds and pushes on v*.*.* tags, plus an edge tag on manual dispatch.
  • .dockerignore extended, README documents the two images.

Note on the Prisma CLI

It could not simply be copied out of the app dependencies: its config loader requires packages the Next.js trace drops, and it needs a writable engines directory. It gets its own install tree under /opt/prisma, pinned to the lockfile version.

Required repository settings

Secrets DOCKERHUB_USERNAME and DOCKERHUB_TOKEN. Optional variable DOCKERHUB_IMAGE to publish under a name other than the default whitemuush/datashield.

Verification

Image built locally and run against the development database: 30 migrations applied, /api/health returns {"status":"ok","db":"up"}, /login serves 200. Lint and compliance hooks pass.

The only image so far was the development one: it bind-mounts the source and
runs `next dev`, so it cannot be distributed. This adds a real production
image and the workflow that publishes it.

The build is multi-stage. Next.js now emits a standalone server bundle, so the
runner carries the traced runtime only instead of the full node_modules. It
runs as the unprivileged `node` user and exposes a healthcheck against
/api/health.

Migrations are applied by the entrypoint before the server starts. The Prisma
CLI could not simply be copied out of the app dependencies (its config loader
pulls packages that the Next.js trace drops), so it gets its own install tree
under /opt/prisma, pinned to the lockfile version. Set RUN_MIGRATIONS=false
when a separate job owns the schema.

The former Dockerfile becomes Dockerfile.dev and compose.yml points at it, so
the local stack is unchanged.

Verified by building the image and running it against the local database:
migrations applied, /api/health returns db up, /login serves 200.
Without a gate, anyone able to push a `v*` tag triggers an immediate public
image push. The job now runs in the `dockerhub` environment, which requires a
manual approval and is restricted to `main`, `develop` and release tags. The
Docker Hub credentials move to that environment as well.
@WhiteMuush WhiteMuush moved this from Todo to In Progress in DataShield Roadmap Sep 2, 2026
@WhiteMuush
WhiteMuush merged commit 6c84cf9 into develop Sep 2, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in DataShield Roadmap Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant