Skip to content

Conversation

@nahSystemu
Copy link
Contributor

This pull request introduces a comprehensive overhaul of the Docker build and deployment process for the web application, resolving issue #315 , focusing on improved Dockerfile layering, distroless production images, runtime environment variable injection, and robust database migration handling. It also enhances the .dockerignore for more efficient builds and updates the docker-compose.yml to support the new workflow. Additionally, there are minor improvements to authentication environment variable handling and Next.js configuration.

Docker build and deployment improvements:

  • Refactored apps/web/Dockerfile to use a multi-stage build, including Alpine-based build stages, a dedicated migration stage, and a final distroless production image for enhanced security and smaller image size. Added a custom bootstrap.cjs script to inject runtime environment variables and start the Next.js server.
  • Added a new migration service and healthchecks in docker-compose.yml, ensuring that database migrations run as a one-off container before starting the web app, and that the web app waits for migration completion.

Build efficiency and configuration:

  • Expanded and reorganized .dockerignore to exclude unnecessary files and directories, reducing Docker build context size and improving build times.
  • Updated apps/web/next.config.js to exclude dev-only dependencies from the standalone output, reducing production image size.
  • Minor fix to image loader configuration in next.config.js for consistency.

Authentication and environment handling:

  • Improved handling of trusted origins in packages/auth/src/auth.ts by filtering out empty values from the environment variable.

Final breakdown of build images:

Image Size Change
ghcr.io/kanbn/kan (official) 2.84 GB
ghcr.io/kanbn/kan (distroless) 343 MB -87.9%
ghcr.io/kanbn/kan-migrate (alpine) 240 MB new
Combined total 583 MB -79.5%

@nahSystemu nahSystemu changed the title refactor: docker image for less final size refactor: docker image for less final size (#315) Feb 11, 2026
@nahSystemu nahSystemu marked this pull request as draft February 11, 2026 18:10
@nahSystemu nahSystemu closed this Feb 11, 2026
@nahSystemu nahSystemu reopened this Feb 11, 2026
@nahSystemu
Copy link
Contributor Author

Tried to get the build to stop, since it froze on a step for 4 hours

@nahSystemu
Copy link
Contributor Author

Shit, it launched another build

@nahSystemu nahSystemu marked this pull request as ready for review February 11, 2026 18:47
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.

1 participant