mirror of
https://github.com/vlang/v.git
synced 2025-09-11 16:36:20 -04:00
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:
parent
31cde9d8f5
commit
f97dd8c4fb
@ -1,37 +1,77 @@
|
|||||||
FROM alpine:3.12
|
FROM alpine:3.20
|
||||||
|
|
||||||
LABEL maintainer="spytheman <spytheman@bulsynt.org>"
|
LABEL maintainer="spytheman <spytheman@bulsynt.org>"
|
||||||
|
|
||||||
WORKDIR /opt/vlang
|
WORKDIR /opt/vlang
|
||||||
|
|
||||||
ENV VVV /opt/vlang
|
|
||||||
ENV PATH /opt/vlang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
ENV PATH /opt/vlang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
ENV VFLAGS -cc gcc
|
|
||||||
|
|
||||||
RUN mkdir -p /opt/vlang && ln -s /opt/vlang/v /usr/bin/v
|
## install development packages
|
||||||
|
|
||||||
ARG USE_LOCAL
|
|
||||||
|
|
||||||
## libexecinfo is needed for the bundled tcc
|
|
||||||
RUN apk --no-cache add \
|
RUN apk --no-cache add \
|
||||||
git make upx gcc bash \
|
musl-dev libc-dev libc6-compat gcompat
|
||||||
musl-dev libc-dev \
|
|
||||||
openssl-dev sqlite-dev \
|
RUN apk --no-cache add \
|
||||||
libx11-dev glfw-dev freetype-dev \
|
openssl-dev sqlite-dev mbedtls \
|
||||||
libexecinfo-dev libexecinfo-static \
|
libuv-dev libev-dev libevent-dev libmemcached-dev
|
||||||
libc6-compat gcompat binutils
|
|
||||||
|
RUN apk --no-cache add \
|
||||||
|
binutils diffutils elfutils pcre strace \
|
||||||
|
libunwind-dev libunwind-static gc
|
||||||
|
|
||||||
|
RUN apk --no-cache add \
|
||||||
|
make bash file git upx
|
||||||
|
|
||||||
|
RUN apk --no-cache add gcc gdb wasi-sdk
|
||||||
|
|
||||||
|
RUN apk --no-cache add \
|
||||||
|
mesa-dev mesa-gl mesa-gles mesa-glapi \
|
||||||
|
glfw-dev \
|
||||||
|
glu-dev \
|
||||||
|
glew-dev \
|
||||||
|
freetype-dev \
|
||||||
|
freeglut-dev \
|
||||||
|
libxi-dev libxi-static \
|
||||||
|
libxcursor-dev \
|
||||||
|
libx11-dev
|
||||||
|
|
||||||
|
RUN apk --no-cache add \
|
||||||
|
icu-data-full \
|
||||||
|
sdl2_net-dev \
|
||||||
|
sdl2_gfx-dev \
|
||||||
|
sdl2_ttf-dev \
|
||||||
|
sdl2_image-dev \
|
||||||
|
sdl2_mixer-dev \
|
||||||
|
sdl2_pango-dev \
|
||||||
|
sdl2-dev
|
||||||
|
|
||||||
|
RUN ln -s /opt/vlang/v /usr/local/bin/v
|
||||||
|
|
||||||
## RUN apk --no-cache add --virtual sdl2deps sdl2-dev sdl2_ttf-dev sdl2_mixer-dev sdl2_image-dev
|
|
||||||
COPY . /vlang-local
|
COPY . /vlang-local
|
||||||
|
|
||||||
|
ARG USE_LOCAL
|
||||||
RUN if [[ -z "${USE_LOCAL}" ]] ; then \
|
RUN if [[ -z "${USE_LOCAL}" ]] ; then \
|
||||||
git clone https://github.com/vlang/v/ /opt/vlang && \
|
git clone --depth=1 --quiet https://github.com/vlang/v/ /opt/vlang && \
|
||||||
rm -rf /vlang-local ; \
|
rm -rf /vlang-local ; \
|
||||||
else \
|
else \
|
||||||
mv /vlang-local/* . && \
|
mv /vlang-local/* . && \
|
||||||
rm -rf /vlang-local ; \
|
rm -rf /vlang-local ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RUN make && v -version
|
RUN mkdir -p /tmp/v /tmp/v /home/ && chown -Rh 1000:1000 /opt/ /tmp/ /home/
|
||||||
|
|
||||||
|
## setup runtime environment for v and bash:
|
||||||
|
USER 1000:1000
|
||||||
|
ENV HOME /home
|
||||||
|
ENV VTMP /tmp/v
|
||||||
|
ENV VMODULES /tmp/vmodules
|
||||||
|
|
||||||
|
RUN make && v -version && ls -la v
|
||||||
|
RUN du -b -s .
|
||||||
|
RUN time v -prod -skip-unused doctor
|
||||||
|
RUN time v -prod -skip-unused self
|
||||||
|
RUN time v -prod -skip-unused cmd/tools/vfmt.v
|
||||||
|
RUN find . -type f -name *_test.v -or -name *.vv -or -name *.out | xargs rm
|
||||||
|
RUN rm -rf v_old vc/ .git/
|
||||||
|
RUN du -b -s .
|
||||||
|
|
||||||
CMD ["v"]
|
CMD ["v"]
|
||||||
|
20
README.md
20
README.md
@ -190,10 +190,26 @@ docker run --rm -it vlang:latest
|
|||||||
```bash
|
```bash
|
||||||
git clone https://github.com/vlang/v
|
git clone https://github.com/vlang/v
|
||||||
cd v
|
cd v
|
||||||
docker build -t vlang --file=Dockerfile.alpine .
|
docker build -t vlang_alpine - < Dockerfile.alpine
|
||||||
docker run --rm -it vlang:latest
|
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>
|
</details>
|
||||||
|
|
||||||
### Termux/Android
|
### Termux/Android
|
||||||
|
Loading…
x
Reference in New Issue
Block a user