rogchap / v8go

Execute JavaScript from Go

Home Page:https://rogchap.com/v8go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Golang Docker Build with v0.9.0

frankgreco opened this issue · comments

It looks like the version of GCC that ships with the official Golang Dcoker containers is too old to work with v0.9.0. I'm getting errors from a Dockerfile that worked with v0.8.0 like this.

undefined reference to `std::__throw_bad_array_new_length()

Here is my Dockerfile 👇🏼

# syntax=docker/dockerfile:experimental

# Allow the Go version to be configured
ARG GO_VERSION=1.20.1

# Builder base image
FROM golang:${GO_VERSION} as builder

# Set a directory to work from
WORKDIR /go/src/github.com/foo/bar

# Install dependencies
RUN dpkg --add-architecture amd64 \
    && apt-get upgrade \
    && apt-get install -y --no-install-recommends gcc-x86-64-linux-gnu g++-x86-64-linux-gnu

# Copy everything in and compile
# There may be cache optimizations we can make
COPY . .

# Some of our dependencies are private, so we need to use SSH to clone them.
RUN git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
RUN mkdir -p ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts


# Build our binary.
RUN --mount=type=ssh GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc CXX=x86_64-linux-gnu-g++ make build-go EXTRA_LD_FLAGS="-s -w -extldflags '-dynamic'"
commented

Thanks for posting this, is the first time I use v8go and I didn't know why doesn't works. Its happen the same to me running with the v0.8.0 version but failing v0.9.0

@frankgreco thanks to your comment about the gcc version, I manged to solve it

FROM golang:bookworm AS opencv-base-local

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -y && apt-get install -y \
      build-essential gcc # ...

@Davincible 🙏🏼 Thanks!! This did it!