github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/Dockerfile (about)

     1  # tinygo-llvm stage obtains the llvm source for TinyGo
     2  FROM golang:1.22 AS tinygo-llvm
     3  
     4  RUN apt-get update && \
     5      apt-get install -y apt-utils make cmake clang-15 ninja-build && \
     6      rm -rf \
     7          /var/lib/apt/lists/* \
     8          /var/log/* \
     9          /var/tmp/* \
    10          /tmp/*
    11  
    12  COPY ./GNUmakefile /tinygo/GNUmakefile
    13  
    14  RUN cd /tinygo/ && \
    15      make llvm-source
    16  
    17  # tinygo-llvm-build stage build the custom llvm with xtensa support
    18  FROM tinygo-llvm AS tinygo-llvm-build
    19  
    20  RUN cd /tinygo/ && \
    21      make llvm-build
    22  
    23  # tinygo-compiler-build stage builds the compiler itself
    24  FROM tinygo-llvm-build AS tinygo-compiler-build
    25  
    26  COPY . /tinygo
    27  
    28  # build the compiler and tools
    29  RUN cd /tinygo/ && \
    30      git submodule update --init && \
    31      make gen-device -j4 && \
    32      make build/release
    33  
    34  # tinygo-compiler copies the compiler build over to a base Go container (without
    35  # all the build tools etc).
    36  FROM golang:1.22 AS tinygo-compiler
    37  
    38  # Copy tinygo build.
    39  COPY --from=tinygo-compiler-build /tinygo/build/release/tinygo /tinygo
    40  
    41  # Configure the container.
    42  ENV PATH="${PATH}:/tinygo/bin"
    43  CMD ["tinygo"]