-
-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build v8go for musl libc (e.g. for alpine linux) #170
Comments
Do you mean Alpine Linux? There is already a linux build of v8go. Are you having any issues with using the pre-built v8 library for linux that is bundled with v8go? |
Yes, I do. It seems that I have to rebuild v8 for Alpine linux (probably because its different std c lib). Below you can see a go code (simple app copied from your README page) and dockerfile. I've also attached the build log. What I found is an old thread how to build v8 on alpine. It would be great to have a precompiled version for alpine linux like there are for Linux, macOS and Windows.
FROM golang:1.17-alpine
WORKDIR /app
COPY go.mod go.sum main.go /app
RUN go mod download
RUN apk add build-base
RUN go build package main
import (
_ "embed"
"fmt"
"rogchap.com/v8go"
)
func main() {
ctx, _ := v8go.NewContext() // creates a new V8 context with a new Isolate aka VM
ctx.RunScript("const add = (a, b) => a + b", "math.js") // executes a script on the global context
ctx.RunScript("const result = add(3, 4)", "main.js") // any functions previously added to the context can be called
val, _ := ctx.RunScript("result", "value.js") // return a value in JavaScript back to Go
fmt.Printf("addition result: %s", val)
} |
I see, it isn't actually creating a fully static executable because of dependencies on the system's libc. If v8 were statically compiled against musl, then perhaps we could completely get rid of the external libc dependency and make the pre-compiled code portable to any linux distribution. |
Note that the Go build constraints don't have builtin build constraint support for distinguishing between linux distributions or libc implementations. So even if we wanted a separate pre-compiled v8 build for alpine linux, it doesn't seem like it could just be automatically be used. However, it does seem like custom build tags could be specified using the |
This also breaks 32bit arm and 32bit x86, and musl libc. Is there no better way to build this on demand? |
@dylanahsmith @krhubert |
Hi!
Is it possible to include alpine os to build pipeline?
The text was updated successfully, but these errors were encountered: