Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions v2/cli_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package main
import (
"context"
"flag"
"fmt"
"os"
"slices"
"strings"

"github.com/discourse/launcher/v2/config"
Expand Down Expand Up @@ -53,6 +55,9 @@ func (r *DockerBuildCmd) Run(cli *Cli, ctx context.Context) error {
ExtraFlags: r.ExtraFlags,
MountVolumes: r.MountVolumes,
}
if builder.ExtraFlags != nil && slices.Contains(builder.ExtraFlags, "--secret") && len(config.Secrets) == 0 {
fmt.Fprintln(utils.Out, "Warning: you must declare your secrets in the configuration file as a list of strings.")
}
if err := builder.Run(ctx); err != nil {
if configErr := config.ValidateConfig(err); configErr != nil {
return configErr
Expand Down
7 changes: 7 additions & 0 deletions v2/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Config struct {
Env map[string]string `yaml:"env,omitempty"`
Labels map[string]string `yaml:"labels,omitempty"`
Volumes []VolumeObject `yaml:"volumes,omitempty"`
Secrets []string `yaml:"secrets,omitempty"`
Links []struct {
Link struct {
Name string `yaml:"name"`
Expand Down Expand Up @@ -185,6 +186,12 @@ func (config *Config) Dockerfile(pupsArgs string, bakeEnv bool, mountVolumes boo
builder.WriteString("--mount=type=bind,from=volume_" + strconv.Itoa(i) + ",source=/,target=" + v.Volume.Guest + ",rw=true ")
}
}

// add secret mounts if any secrets exist
for _, secret := range config.Secrets {
builder.WriteString("--mount=type=secret,id=" + secret + " ")
}

builder.WriteString(
"cat /temp-config.yaml | /usr/local/bin/pups " + pupsArgs + " --stdin " +
"&& rm /temp-config.yaml\n")
Expand Down