Skip to content

Instantly share code, notes, and snippets.

@chrmoritz
Forked from hayd/Dockerfile
Last active November 2, 2019 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrmoritz/b9a1a73722c3591e244e6d9aa6ca84bc to your computer and use it in GitHub Desktop.
Save chrmoritz/b9a1a73722c3591e244e6d9aa6ca84bc to your computer and use it in GitHub Desktop.
#FROM amazonlinux:2017.03.1.20170812
FROM amazonlinux:2018.03.0.20191014.0
# We're trying to build deno in Amazon Linux 1.
RUN yum install -y curl unzip
# Note: 1.9.0 does not run without glibc.
ENV NINJA_VERSION=1.9.0
RUN curl -fsSL https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-linux.zip --output ninja.zip \
&& unzip ninja.zip \
&& mv ninja /bin/ninja \
&& rm ninja.zip
# TODO specify a version of gn here rather than "latest"
ENV GN_VERSION=latest
RUN curl -fL https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/${GN_VERSION} --output gn.zip \
&& unzip gn.zip gn \
&& mv gn /bin/gn \
&& rm gn.zip
RUN yum install -y xz
RUN curl -fL http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-sles11.3.tar.xz --output /tmp/clang.tar.xz \
&& tar xf /tmp/clang.tar.xz -C /tmp \
&& rm /tmp/clang.tar.xz \
&& mv /tmp/clang+llvm-9.0.0-x86_64-linux-sles11.3 /tmp/clang-llvm
ENV PATH=/tmp/clang-llvm/bin:$PATH
# TODO specify the version here rather than "stable"
RUN curl https://sh.rustup.rs -sSf | \
sh -s -- --default-toolchain stable -y
ENV PATH=/root/.cargo/bin:$PATH
ENV DENO_BUILD_MODE=release
ENV DENO_VERSION 0.22.0
RUN curl -fsSL https://github.com/denoland/deno/releases/download/v${DENO_VERSION}/deno_src.tar.gz --output deno.tar.gz \
&& tar -zxf deno.tar.gz \
&& rm deno.tar.gz
RUN cp /bin/gn /deno/core/libdeno/buildtools/linux64/gn
RUN yum install -y gcc-c++ libatomic
RUN echo "INPUT ( /usr/lib64/libatomic.so.1.2.0 )" > "/usr/lib/gcc/x86_64-amazon-linux/4.8.5/libatomic.so"
WORKDIR /deno/cli
RUN RUST_BACKTRACE=1 DENO_NO_BINARY_DOWNLOAD=1 DENO_BUILD_ARGS='clang_use_chrome_plugins=false treat_warnings_as_errors=false use_sysroot=false clang_base_path="/tmp/clang-llvm" use_glib=false use_gold=true' DENO_GN_PATH=gn cargo install --locked --root .. --path . || echo error
ENTRYPOINT ["/bin/bash"]
@chrmoritz
Copy link
Author

chrmoritz commented Nov 2, 2019

@hayd: This works for me using Googles custom libcxx

@hayd
Copy link

hayd commented Nov 2, 2019

Amazing! I'd like to copy this into deno_docker (with MIT licence). Is that okay?

Though honestly playing spot the difference here is very tricky!
(I was sure ninja needed to be 1.8.2 😮 )

I can confirm this runs AND the binary can be extracted to a clean install.

@chrmoritz
Copy link
Author

chrmoritz commented Nov 2, 2019

Sure, you can use it.

The diff https://gist.github.com/chrmoritz/b9a1a73722c3591e244e6d9aa6ca84bc/revisions is just the (probably unneeded) ninja upgrade to 1.9.0 and removing CPATH and use_custom_libcxx* gn args to use Googles libc++.

@hayd
Copy link

hayd commented Nov 2, 2019

Thank you!

I was wondering if it/you might also fix denoland/deno#3243 it feels very similar.
(I will continue to try some more permutations...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment