mattn / mattn/go-sqlite3

error when running on SCRATCH image ( partially solved )

Open
#1,087 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
9.2k
Forks
1.2k
Avg merge
19m
Merged PRs (30d)
4

Description

Hello everyone, I tried to build a module using your go-sqlite3 package and run the resulting binary inside a SCRATCH image.

The build is done inside a github ubuntu runner, with basic go-install action + apt-install build-essential.

Unfortunately when running the container, I got a runtime error which was exec /go/src/{my_binary_name}: no such file or directory

After various search found out it was due to dynamic linking, managed to make everything works by adding those flags to the goreleaser

    ldflags: -s -w -linkmode external -extldflags "-static"
    flags: --tags netgo

I am not good enough to understand what happens under the hood, and why it solved it, but maybe it could be usefull to some people to improve the documentation and this use case.

Ps: can provide more details in order to reproduce it, just let me know.

Regards,
JC

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Go binary in a SCRATCH container and compare the working Goreleaser ldflags and netgo setting with the failing build. Document the relevant static-linking configuration and the expected container runtime result, using the reporter's reproduction details if provided.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sqlite
Domain
build-system, devops, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.