fixed backend code

This commit is contained in:
dhaval055
2023-10-09 17:57:34 +00:00
parent c7fc95831f
commit 6fbc916902
3 changed files with 57 additions and 61 deletions
+1 -3
View File
@@ -8,8 +8,6 @@ ADD ./go-app/main.go /app
ADD ./go-app/walkoff.go /app ADD ./go-app/walkoff.go /app
ADD ./go-app/docker.go /app ADD ./go-app/docker.go /app
ADD ./go-app/shuffle-shared /app/shuffle-shared
ADD ./go-app/go.mod /app ADD ./go-app/go.mod /app
# Required files for code generation # Required files for code generation
@@ -43,4 +41,4 @@ COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certifica
WORKDIR /app WORKDIR /app
EXPOSE 5001 EXPOSE 5001
CMD ["./webapp"] CMD ["./webapp"]
+54 -56
View File
@@ -463,72 +463,70 @@ func buildImage(tags []string, dockerfileFolder string) error {
} }
} else { } else {
//docker part here ctx := context.Background()
client, err := client.NewEnvClient()
if err != nil {
log.Printf("Unable to create docker client: %s", err)
return err
} }
// ctx := context.Background() log.Printf("[INFO] Docker Tags: %s", tags)
// client, err := client.NewEnvClient() dockerfileSplit := strings.Split(dockerfileFolder, "/")
// if err != nil {
// log.Printf("Unable to create docker client: %s", err)
// return err
// }
// log.Printf("[INFO] Docker Tags: %s", tags) // Create a buffer
// dockerfileSplit := strings.Split(dockerfileFolder, "/") buf := new(bytes.Buffer)
tw := tar.NewWriter(buf)
defer tw.Close()
baseDir := strings.Join(dockerfileSplit[0:len(dockerfileSplit)-1], "/")
// // Create a buffer // Builds the entire folder into buf
// buf := new(bytes.Buffer) err = getParsedTar(tw, baseDir, "")
// tw := tar.NewWriter(buf) if err != nil {
// defer tw.Close() log.Printf("Tar issue: %s", err)
// baseDir := strings.Join(dockerfileSplit[0:len(dockerfileSplit)-1], "/") }
// // Builds the entire folder into buf dockerFileTarReader := bytes.NewReader(buf.Bytes())
// err = getParsedTar(tw, baseDir, "") buildOptions := types.ImageBuildOptions{
// if err != nil { Remove: true,
// log.Printf("Tar issue: %s", err) Tags: tags,
// } BuildArgs: map[string]*string{},
}
//NetworkMode: "host",
// dockerFileTarReader := bytes.NewReader(buf.Bytes()) httpProxy := os.Getenv("HTTP_PROXY")
// buildOptions := types.ImageBuildOptions{ if len(httpProxy) > 0 {
// Remove: true, buildOptions.BuildArgs["HTTP_PROXY"] = &httpProxy
// Tags: tags, }
// BuildArgs: map[string]*string{}, httpsProxy := os.Getenv("HTTPS_PROXY")
// } if len(httpProxy) > 0 {
// //NetworkMode: "host", buildOptions.BuildArgs["https_proxy"] = &httpsProxy
}
// httpProxy := os.Getenv("HTTP_PROXY") // Build the actual image
// if len(httpProxy) > 0 { imageBuildResponse, err := client.ImageBuild(
// buildOptions.BuildArgs["HTTP_PROXY"] = &httpProxy ctx,
// } dockerFileTarReader,
// httpsProxy := os.Getenv("HTTPS_PROXY") buildOptions,
// if len(httpProxy) > 0 { )
// buildOptions.BuildArgs["https_proxy"] = &httpsProxy
// }
// // Build the actual image if err != nil {
// imageBuildResponse, err := client.ImageBuild( return err
// ctx, }
// dockerFileTarReader,
// buildOptions,
// )
// if err != nil { // Read the STDOUT from the build process
// return err defer imageBuildResponse.Body.Close()
// } buildBuf := new(strings.Builder)
_, err = io.Copy(buildBuf, imageBuildResponse.Body)
// // Read the STDOUT from the build process if err != nil {
// defer imageBuildResponse.Body.Close() return err
// buildBuf := new(strings.Builder) } else {
// _, err = io.Copy(buildBuf, imageBuildResponse.Body) if strings.Contains(buildBuf.String(), "errorDetail") {
// if err != nil { log.Printf("[ERROR] Docker build:\n%s\nERROR ABOVE: Trying to pull tags from: %s", buildBuf.String(), strings.Join(tags, "\n"))
// return err return errors.New(fmt.Sprintf("Failed building %s. Check backend logs for details. Most likely means you have an old version of Docker.", strings.Join(tags, ",")))
// } else { }
// if strings.Contains(buildBuf.String(), "errorDetail") { }
// log.Printf("[ERROR] Docker build:\n%s\nERROR ABOVE: Trying to pull tags from: %s", buildBuf.String(), strings.Join(tags, "\n"))
// return errors.New(fmt.Sprintf("Failed building %s. Check backend logs for details. Most likely means you have an old version of Docker.", strings.Join(tags, ",")))
// }
// }
}
return nil return nil
} }
+2 -2
View File
@@ -1,6 +1,6 @@
module shuffle-shared module shuffle-shared
replace github.com/shuffle/shuffle-shared => /app/shuffle-shared // replace github.com/shuffle/shuffle-shared => /app/shuffle-shared
go 1.19 go 1.19
@@ -19,7 +19,7 @@ require (
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/h2non/filetype v1.1.3 github.com/h2non/filetype v1.1.3
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/shuffle/shuffle-shared v0.4.19 github.com/shuffle/shuffle-shared v0.4.50
golang.org/x/crypto v0.9.0 golang.org/x/crypto v0.9.0
google.golang.org/api v0.125.0 google.golang.org/api v0.125.0
google.golang.org/appengine v1.6.7 google.golang.org/appengine v1.6.7