From 316cc5ecc10ecc6dc0bec75d3714dabce96c9a6c Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 15 Feb 2023 15:43:24 +0100 Subject: [PATCH] feat: added vlang dockerfile --- README.md | 21 +++++++++++++++++++ vlang/Dockerfile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 vlang/Dockerfile diff --git a/README.md b/README.md index a7445f2..4adf48f 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,24 @@ Vieter requires several tools to be developed, one of which being a specific version of Vlang. This repository manages Dockerfiles & other packages for these various tools. + +## Build instructions + +Most stuff in this repository is built automatically using my CI. These +instructions can be found in [`.woodpecker`](./.woodpecker). + +### Vlang Docker image + +The Vlang Docker image takes too long to build on my CI, mostly because it +needs to be built for both arm64 & aarch64. It can be built by running the +following command in the `vlang` directory: + +```sh +docker buildx build \ + --platform linux/amd64,linux/arm64 \ + -t 'git.rustybever.be/chewing_bever/vlang:d1f57ead713c8e5254d8cef22991e6409dc1f06b-alpine3.17' \ + -t 'git.rustybever.be/chewing_bever/vlang:latest' \ + --push . +``` + +The hash in the tag corresponds to the tag of the vlang repository. diff --git a/vlang/Dockerfile b/vlang/Dockerfile new file mode 100644 index 0000000..819e9bb --- /dev/null +++ b/vlang/Dockerfile @@ -0,0 +1,52 @@ +FROM alpine:3.17 + +ARG TARGETPLATFORM + +ARG V_COMMIT_HASH=d1f57ead713c8e5254d8cef22991e6409dc1f06b +ARG VC_COMMIT_HASH=1f7f0244f352d41122bb306446d98ae3de4e6b02 + +ENV VVV /opt/vlang +ENV PATH /opt/vlang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ENV VFLAGS -cc gcc -gc none + +RUN apk --no-cache add \ + git make gcc curl musl-dev \ + openssl openssl-libs-static openssl-dev \ + sqlite-static sqlite-dev \ + libarchive-static libarchive-dev \ + zlib-static zlib-dev \ + bzip2-static bzip2-dev \ + xz-static xz-dev \ + expat-static expat-dev \ + zstd zstd-dev \ + lz4-static lz4-dev \ + diffutils \ + mandoc unzip + +WORKDIR /opt + +RUN curl -Lo v.zip "https://github.com/vlang/v/archive/${V_COMMIT_HASH}.zip" && \ + unzip v.zip && \ + rm v.zip && \ + mv "v-${V_COMMIT_HASH}" vlang + +WORKDIR /opt/vlang + +# We use zip instead of git for the vc repository here because cloning it +# requires pulling down over 600MB of Git history. +RUN curl -Lo vc.zip "https://github.com/vlang/vc/archive/${VC_COMMIT_HASH}.zip" && \ + unzip vc.zip && \ + rm vc.zip && \ + mv "vc-${VC_COMMIT_HASH}" vc && \ + make fresh_tcc && \ + make local=1 prod=1 && \ + ln -s /opt/vlang/v /usr/bin/v + +# This is used to upload the resulting static binaries to my Minio instance. +# There are however only builds available for amd64. +RUN if [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \ + wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && \ + chmod +x /usr/local/bin/mc ; \ +fi + +CMD ["v"]