rogchap / v8go

Execute JavaScript from Go
https://rogchap.com/v8go
BSD 3-Clause "New" or "Revised" License
3.21k stars 221 forks source link

Golang Docker Build with v0.9.0 #381

Closed frankgreco closed 1 year ago

frankgreco commented 1 year ago

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'"
kowiste commented 1 year ago

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 commented 1 year ago

cc @rogchap

Davincible commented 1 year ago

@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 # ...
frankgreco commented 1 year ago

@Davincible ๐Ÿ™๐Ÿผ Thanks!! This did it!