andreas-wilm / lofreq3

LoFreq Version 3
MIT License
27 stars 0 forks source link

Setup static binary build #31

Closed andreas-wilm closed 3 years ago

andreas-wilm commented 3 years ago

See https://github.com/brentp/hts-nim#static-builds

andreas-wilm commented 3 years ago

Upgrade Nim build in Dockerfile to 1.4.2 and use new Docker image

andreas-wilm commented 3 years ago

Cloned hts-nim.git. Removed rust and d4 because of build error. Upgraded to Nim 1.4.2. Build and tagged image: docker build --no-cache -t hts-nim-1.4.2. Used that tag in hts_nim_static_builder and rebuild.

Linker fails with multiple definition of:

andreas-wilm commented 3 years ago

Full hts-nim diff (against 13ccd28) for reference

diff --git a/Dockerfile b/Dockerfile
index eca2760..7d2c3e9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,7 +16,7 @@ RUN mkdir -p /usr/local/include && \
     rm -rf cloudflare-zlib

 RUN cd / && \
-    git clone -b v1.2.6 git://github.com/nim-lang/nim nim && \
+    git clone -b v1.4.2 git://github.com/nim-lang/nim nim && \
     cd nim &&  \
     sh ./build_all.sh && \
     rm -rf csources && \
@@ -49,23 +49,23 @@ RUN \
     cd ../ && rm -rf htslib bcftools

-RUN sh -c 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y'
+#RUN sh -c 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y'
 #      && apk add clang-libs

-ENV HTSLIB=system
-ENV PATH=$PATH:~/.cargo/bin/
+#ENV HTSLIB=system
+#ENV PATH=$PATH:~/.cargo/bin/

 #COPY docker/d4.patch /tmp/

 #&& git apply < /tmp/d4.patch \
-RUN ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \
-   && git clone https://github.com/38/d4-format \
-   && cd d4-format \
-        && ln -s /usr/bin/gcc /usr/bin/musl-gcc \
-   && ~/.cargo/bin/cargo build --all --target x86_64-unknown-linux-musl --release
-
-RUN install -m 644 d4-format/target/x86_64-unknown-linux-musl/release/libd4binding.a /usr/lib && \
-   install -m 644 d4-format/d4binding/include/d4.h /usr/include
+#RUN ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \
+#  && git clone https://github.com/38/d4-format \
+#  && cd d4-format \
+#        && ln -s /usr/bin/gcc /usr/bin/musl-gcc \
+#  && ~/.cargo/bin/cargo build --all --target x86_64-unknown-linux-musl --release
+
+#RUN install -m 644 d4-format/target/x86_64-unknown-linux-musl/release/libd4binding.a /usr/lib && \
+#  install -m 644 d4-format/d4binding/include/d4.h /usr/include

 ADD . /src/
diff --git a/docker/docker.nim.cfg b/docker/docker.nim.cfg
index 7f29f73..86d9a6b 100644
--- a/docker/docker.nim.cfg
+++ b/docker/docker.nim.cfg
@@ -24,7 +24,7 @@
   passl:"/usr/lib/libc.a"
   passl:"/usr/lib/librt.a"
   passl:"/usr/lib/libpcre.a"
-  passl:"/usr/lib/libd4binding.a"
+  #passl:"/usr/lib/libd4binding.a"

 #  passl:"/usr/local/lib/libnghttp2.a"
 #  passl:"/usr/lib/libcurl.a"
diff --git a/docker/hts_nim_static_builder.nim b/docker/hts_nim_static_builder.nim
index c18e1d8..896d636 100644
--- a/docker/hts_nim_static_builder.nim
+++ b/docker/hts_nim_static_builder.nim
@@ -48,7 +48,8 @@ else:
    dir = d

 # file gets build and sent to /load so it appears in the users pwd
-var cmd = &"""docker run -v {dir}:{dir} -v {getCurrentDir()}:/load/ brentp/musl-hts-nim:{$args["--tag"]} /usr/local/bin/nsb """
+#var cmd = &"""docker run -v {dir}:{dir} -v {getCurrentDir()}:/load/ brentp/musl-hts-nim:{$args["--tag"]} /usr/local/bin/nsb """
+var cmd = &"""docker run -v {dir}:{dir} -v {getCurrentDir()}:/load/ hts-nim-1.4.2:{$args["--tag"]} /usr/local/bin/nsb """
 if $args["--nimble-file"] != "nil":
   cmd &= &"""-n {nimblePath}"""