From e0593fa98f6e0b5594ef85c6c2db14d4f2fc0c66 Mon Sep 17 00:00:00 2001 From: maddalax Date: Sun, 22 Sep 2024 22:41:36 -0500 Subject: [PATCH] dont build atm --- cli/htmgo/tasks/run/build.go | 15 +++++++-------- examples/todo-list/Dockerfile | 11 +++++++++-- htmgo-site/Dockerfile | 6 ++++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/cli/htmgo/tasks/run/build.go b/cli/htmgo/tasks/run/build.go index c20c28a..9653e01 100644 --- a/cli/htmgo/tasks/run/build.go +++ b/cli/htmgo/tasks/run/build.go @@ -6,7 +6,6 @@ import ( "github.com/maddalax/htmgo/cli/htmgo/tasks/copyassets" "github.com/maddalax/htmgo/cli/htmgo/tasks/css" "github.com/maddalax/htmgo/cli/htmgo/tasks/process" - "os" ) func Build() { @@ -20,13 +19,13 @@ func Build() { process.RunOrExit("rm -rf ./dist") process.RunOrExit("mkdir -p ./dist") - flags := "" - if os.Getenv("CGO_ENABLED") == "1" { - flags = `-a -ldflags '-linkmode external -extldflags "-static"' ` - } - - process.RunOrExit(fmt.Sprintf("go build -o ./dist/app %s.", flags)) - process.RunOrExit(fmt.Sprintf("go build -o ./dist/app %s.", flags)) + //flags := "" + //if os.Getenv("CGO_ENABLED") == "1" { + // flags = `-a -ldflags '-linkmode external -extldflags "-static"' ` + //} + // + //process.RunOrExit(fmt.Sprintf("go build -o ./dist %s.", flags)) + //process.RunOrExit(fmt.Sprintf("go build -o ./dist/app %s .", flags)) fmt.Printf("Executable built at %s\n", process.GetPathRelativeToCwd("dist")) } diff --git a/examples/todo-list/Dockerfile b/examples/todo-list/Dockerfile index 715980e..d19fd92 100644 --- a/examples/todo-list/Dockerfile +++ b/examples/todo-list/Dockerfile @@ -16,10 +16,17 @@ RUN go get github.com/maddalax/htmgo/framework@latest # Copy the source code into the container COPY . . -RUN CGO_ENABLED=1 GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest build +RUN CGO_ENABLED=1 GOOS=linux go build -o ./dist -a -ldflags '-linkmode external -extldflags "-static"' . + +# Build the Go binary for Linux +RUN CGO_ENABLED=0 GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest build + +RUN ls + +RUN cd dist && ls # Stage 2: Create the smallest possible image -FROM gcr.io/distroless/base-debian11 +FROM golang:1.23 # Set the working directory inside the container WORKDIR /app diff --git a/htmgo-site/Dockerfile b/htmgo-site/Dockerfile index 5cebac7..87d85bb 100644 --- a/htmgo-site/Dockerfile +++ b/htmgo-site/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build the Go binary -FROM golang:1.23-alpine AS builder +FROM golang:1.23 AS builder RUN apk update RUN apk add git @@ -20,8 +20,10 @@ RUN go get github.com/maddalax/htmgo/framework@latest # Copy the source code into the container COPY . . +RUN CGO_ENABLED=1 GOOS=linux go build -o ./dist -a -ldflags '-linkmode external -extldflags "-static"' . + # Build the Go binary for Linux -RUN GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest build +RUN CGO_ENABLED=0 GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest build # Stage 2: Create the smallest possible image