Dockerfile.alpine: update to alpine:3.20, add more tools like gdb, libunwind, gc, to ease producing and debugging static executable in more situations (#21583)

This commit is contained in:
Delyan Angelov 2024-05-27 20:12:05 +03:00 committed by GitHub
parent 31cde9d8f5
commit f97dd8c4fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 75 additions and 19 deletions

View file

@ -190,10 +190,26 @@ docker run --rm -it vlang:latest
```bash
git clone https://github.com/vlang/v
cd v
docker build -t vlang --file=Dockerfile.alpine .
docker run --rm -it vlang:latest
docker build -t vlang_alpine - < Dockerfile.alpine
alias with_alpine='docker run -u 1000:1000 --rm -it -v .:/src -w /src vlang_alpine:latest'
```
Compiling *static* executables, ready to be copied to a server, that is running
another linux distro, without dependencies:
```bash
with_alpine v -skip-unused -prod -cc gcc -cflags -static -compress examples/http_server.v
with_alpine v -skip-unused -prod -cc gcc -cflags -static -compress -gc none examples/hello_world.v
ls -la examples/http_server examples/hello_world
file examples/http_server examples/hello_world
examples/http_server: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, no section header
examples/hello_world: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, no section header
```
You should see something like this:
```
-rwxr-xr-x 1 root root 16612 May 27 17:07 examples/hello_world
-rwxr-xr-x 1 root root 335308 May 27 17:07 examples/http_server
```
</details>
### Termux/Android