From 792be866cbc4aa2ad61ea41e00e434a2e1009af0 Mon Sep 17 00:00:00 2001 From: Miu Date: Sat, 4 Jan 2025 19:10:19 +0800 Subject: [PATCH] Update README.md --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 98aee7d..362d706 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,27 @@ func main() { ``` Korin scans the codebase (excluding files listed in `.korignore`), preprocesses required files, and outputs them to the configured build directory (default: `.build`). +### Using Korin as a Docker Buildstep +We recommend using Korin as a build step in Dockerfile to ensure that the code is preprocessed before building. To use Korin as a Docker build step, we recommend creating a +file called `cmd/korin_build.go` and adding the following: +```go +package main + +import "github.com/ShindouMihou/korin/pkg/korin" + +func main() { + korin := korin.New() + + // Uncomment to silence the logger (error logs during preprocessing remain unaffected) + // korin.Logger = kbuild.NoOpLogger + + korin.DockerBuildStep(".") // Replace with your path to source files if it isn't "." +} +``` + +Once done, you can add `RUN go run cmd/korin_build.go` as a Docker step and it should preprocess the files beforehand. It is recommended to use this method over `Build` and +related since it will exit the program with an exit code when it fails to preprocess a specific file. + ### Plugins To create a plugin, you can read about it in the [Creating a Plugin](docs/creating_a_plugin.md) documentation, otherwise, you can check out the [native plugins](pkg/kplugins) that are already available, these should have the `plugin_` prefix on their filenames, by @@ -129,4 +150,4 @@ Korin processes a 2,000-4,000 line codebase in under 5-10 milliseconds on averag Korin is licensed under the [MIT License](LICENSE). You are free to use, modify, and distribute this project in compliance with the license terms. --- -Elevate your Golang projects with Korin's seamless preprocessing capabilities! \ No newline at end of file +Elevate your Golang projects with Korin's seamless preprocessing capabilities!