aboutsummaryrefslogtreecommitdiffhomepage
path: root/Dockerfile
blob: 72dad9b9ffc61c3088e4165411f5952c49874d48 (plain)
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
# tinygo-llvm stage obtains the llvm source for TinyGo
FROM golang:1.21 AS tinygo-llvm

RUN apt-get update && \
    apt-get install -y apt-utils make cmake clang-15 ninja-build && \
    rm -rf \
        /var/lib/apt/lists/* \
        /var/log/* \
        /var/tmp/* \
        /tmp/*

COPY ./GNUmakefile /tinygo/GNUmakefile

RUN cd /tinygo/ && \
    make llvm-source

# tinygo-llvm-build stage build the custom llvm with xtensa support
FROM tinygo-llvm AS tinygo-llvm-build

RUN cd /tinygo/ && \
    make llvm-build

# tinygo-compiler stage builds the compiler itself
FROM tinygo-llvm-build AS tinygo-compiler

COPY . /tinygo

# update submodules
RUN cd /tinygo/ && \
    rm -rf ./lib/*/ && \
    git submodule sync && \
    git submodule update --init --recursive --force

RUN cd /tinygo/ && \
    make

# tinygo-tools stage installs the needed dependencies to compile TinyGo programs for all platforms.
FROM tinygo-compiler AS tinygo-tools

RUN cd /tinygo/ && \
    make wasi-libc binaryen && \
    make gen-device -j4 && \
    cp build/* $GOPATH/bin/

CMD ["tinygo"]