Build the engine container
( ctx context.Context, // +optional platform dagger.Platform, // +optional gpuSupport bool, // +optional version string, // +optional tag string, )
| 141 | |
| 142 | // Build the engine container |
| 143 | func (dev *EngineDev) Container( |
| 144 | ctx context.Context, |
| 145 | |
| 146 | // +optional |
| 147 | platform dagger.Platform, |
| 148 | // +optional |
| 149 | gpuSupport bool, |
| 150 | // +optional |
| 151 | version string, |
| 152 | // +optional |
| 153 | tag string, |
| 154 | ) (*dagger.Container, error) { |
| 155 | cfg, err := generateConfig(dev.LogLevel) |
| 156 | if err != nil { |
| 157 | return nil, err |
| 158 | } |
| 159 | engineTOML, err := generateEngineTOML(dev.EngineConfig) |
| 160 | if err != nil { |
| 161 | return nil, err |
| 162 | } |
| 163 | entrypoint, err := generateEntrypoint() |
| 164 | if err != nil { |
| 165 | return nil, err |
| 166 | } |
| 167 | |
| 168 | builder, err := build.NewBuilder(ctx, dev.Source, version, tag) |
| 169 | if err != nil { |
| 170 | return nil, err |
| 171 | } |
| 172 | builder = builder.WithRace(dev.Race) |
| 173 | if platform != "" { |
| 174 | builder = builder.WithPlatform(platform) |
| 175 | } |
| 176 | |
| 177 | if gpuSupport { |
| 178 | builder = builder.WithGPUSupport() |
| 179 | } |
| 180 | |
| 181 | ctr, err := builder.Engine(ctx) |
| 182 | if err != nil { |
| 183 | return nil, err |
| 184 | } |
| 185 | for _, prog := range dev.EBPFProgs { |
| 186 | ctr = ctr.WithEnvVariable("DAGGER_EBPF_PROG_"+strings.ToUpper(prog), "y") |
| 187 | } |
| 188 | |
| 189 | ctr = ctr. |
| 190 | WithFile(engineJSONPath, cfg). |
| 191 | WithFile(engineTOMLPath, engineTOML). |
| 192 | WithFile(engineEntrypointPath, entrypoint). |
| 193 | WithEntrypoint([]string{filepath.Base(engineEntrypointPath)}) |
| 194 | |
| 195 | cli := dag.DaggerCli(dagger.DaggerCliOpts{ |
| 196 | Version: version, |
| 197 | ImageTag: tag, |
| 198 | }).Binary(dagger.DaggerCliBinaryOpts{ |
| 199 | Platform: platform, |
| 200 | }) |
no test coverage detected