forked from bandprotocol/go-owasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.osx
58 lines (44 loc) · 1.6 KB
/
Dockerfile.osx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Currently unavailable
# FROM rust:1.39
# We need nightly currently for compiling with singlepass
FROM rustlang/rust:nightly
RUN apt-get update
RUN apt install -y clang gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev
RUN apt install -y build-essential wget cmake
# add some llvm configs for later - how to cross-compile this in wasmer-llvm-backend???
RUN echo deb http://deb.debian.org/debian buster-backports main >> /etc/apt/sources.list
RUN apt-get update
RUN apt install -y libllvm8 llvm-8 llvm-8-dev llvm-8-runtime
ENV LLVM_SYS_80_PREFIX=/usr/lib/llvm-8
## ADD MACOS SUPPORT
WORKDIR /opt
# Pin to proper nightly and add macOS Rust target
RUN rustup default nightly-2020-06-08
RUN rustup target add x86_64-apple-darwin
# Build osxcross
RUN git clone https://github.com/tpoechtrager/osxcross
RUN cd osxcross && \
wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz && \
mv MacOSX10.10.sdk.tar.xz tarballs/ && \
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
RUN chmod +rx /opt/osxcross
RUN chmod +rx /opt/osxcross/target
RUN chmod -R +rx /opt/osxcross/target/bin
## TODO: add support for windows cross-compile
# PRE-FETCH MANY DEPS
WORKDIR /scratch
COPY owasm /scratch/owasm
COPY go-owasm /scratch/go-owasm
RUN cd go-owasm && cargo fetch
# allow non-root user to download more deps later
RUN chmod -R 777 /usr/local/cargo
RUN chmod -R 777 /usr/local/rustup
## COPY BUILD SCRIPTS
WORKDIR /code
RUN rm -rf /scratch
COPY go-owasm/build/*.sh /opt/
RUN chmod +x /opt/*.sh
RUN mkdir /.cargo
RUN chmod +rx /.cargo
COPY go-owasm/build/cargo-config /.cargo/config
CMD ["/opt/build_osx.sh"]