fix(build): make sure the docker image can access go tools
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2023-04-02 18:55:30 +02:00
parent 791a57d320
commit 01fb738dc8
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 14 additions and 4 deletions

View File

@ -13,7 +13,8 @@ COPY . ./
ARG TARGETOS TARGETARCH TARGETVARIANT ARG TARGETOS TARGETARCH TARGETVARIANT
RUN mage build:clean && \ RUN export PATH=$PATH:$GOPATH/bin && \
mage build:clean && \
mage release:xgo "${TARGETOS}/${TARGETARCH}/${TARGETVARIANT}" mage release:xgo "${TARGETOS}/${TARGETARCH}/${TARGETVARIANT}"
# ┬─┐┬ ┐┌┐┐┌┐┐┬─┐┬─┐ # ┬─┐┬ ┐┌┐┐┌┐┐┬─┐┬─┐

View File

@ -195,7 +195,11 @@ func runAndStreamOutput(cmd string, args ...string) {
stdout, _ := c.StdoutPipe() stdout, _ := c.StdoutPipe()
errbuf := bytes.Buffer{} errbuf := bytes.Buffer{}
c.Stderr = &errbuf c.Stderr = &errbuf
c.Start() err := c.Start()
if err != nil {
fmt.Printf("Could not start: %s\n", err)
os.Exit(1)
}
reader := bufio.NewReader(stdout) reader := bufio.NewReader(stdout)
line, err := reader.ReadString('\n') line, err := reader.ReadString('\n')
@ -337,11 +341,13 @@ func Fmt() {
runAndStreamOutput("gofmt", args...) runAndStreamOutput("gofmt", args...)
} }
const swaggerDocsFolderLocation = `./pkg/swagger/`
// Generates the swagger docs from the code annotations // Generates the swagger docs from the code annotations
func DoTheSwag() { func DoTheSwag() {
mg.Deps(initVars) mg.Deps(initVars)
if _, err := os.Stat("./pkg/swagger/swagger.json"); err == nil { if _, err := os.Stat(swaggerDocsFolderLocation + "swagger.json"); err == nil {
fmt.Println("Swagger docs already generated, not generating. Remove the files in pkg/swagger and run this command again to regenerate them.") fmt.Println("Swagger docs already generated, not generating. Remove the files in " + swaggerDocsFolderLocation + " and run this command again to regenerate them.")
return return
} }
@ -451,6 +457,9 @@ func (Build) Clean() error {
if err := os.RemoveAll(BinLocation); err != nil && !os.IsNotExist(err) { if err := os.RemoveAll(BinLocation); err != nil && !os.IsNotExist(err) {
return err return err
} }
if err := os.RemoveAll(swaggerDocsFolderLocation); err != nil && !os.IsNotExist(err) {
return err
}
return nil return nil
} }