github.com/aykevl/tinygo@v0.5.0/Dockerfile (about)

     1  # TinyGo base stage just installs LLVM 8 and the TinyGo compiler itself.
     2  FROM golang:latest AS tinygo-base
     3  
     4  RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \
     5      echo "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-8 main" >> /etc/apt/sources.list && \
     6      apt-get update && \
     7      apt-get install -y llvm-8-dev libclang-8-dev git
     8  
     9  RUN wget -O- https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
    10  
    11  COPY . /go/src/github.com/tinygo-org/tinygo
    12  
    13  RUN cd /go/src/github.com/tinygo-org/tinygo/ && \
    14      git submodule update --init
    15  
    16  RUN cd /go/src/github.com/tinygo-org/tinygo/ && \
    17      dep ensure --vendor-only && \
    18      go install /go/src/github.com/tinygo-org/tinygo/
    19  
    20  # tinygo-wasm stage installs the needed dependencies to compile TinyGo programs for WASM.
    21  FROM tinygo-base AS tinygo-wasm
    22  
    23  COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo
    24  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/src /go/src/github.com/tinygo-org/tinygo/src
    25  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/targets /go/src/github.com/tinygo-org/tinygo/targets
    26  
    27  RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \
    28      echo "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-8 main" >> /etc/apt/sources.list && \
    29      apt-get update && \
    30      apt-get install -y libllvm8 lld-8
    31  
    32  # tinygo-avr stage installs the needed dependencies to compile TinyGo programs for AVR microcontrollers.
    33  FROM tinygo-base AS tinygo-avr
    34  
    35  COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo
    36  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/src /go/src/github.com/tinygo-org/tinygo/src
    37  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/targets /go/src/github.com/tinygo-org/tinygo/targets
    38  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/Makefile /go/src/github.com/tinygo-org/tinygo/
    39  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/tools /go/src/github.com/tinygo-org/tinygo/tools
    40  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/lib /go/src/github.com/tinygo-org/tinygo/lib
    41  
    42  RUN cd /go/src/github.com/tinygo-org/tinygo/ && \
    43      apt-get update && \
    44      apt-get install -y apt-utils python3 make binutils-avr gcc-avr avr-libc && \
    45      make gen-device-avr && \
    46      apt-get remove -y python3 make && \
    47      apt-get autoremove -y && \
    48      apt-get clean
    49  
    50  # tinygo-arm stage installs the needed dependencies to compile TinyGo programs for ARM microcontrollers.
    51  FROM tinygo-base AS tinygo-arm
    52  
    53  COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo
    54  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/src /go/src/github.com/tinygo-org/tinygo/src
    55  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/targets /go/src/github.com/tinygo-org/tinygo/targets
    56  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/Makefile /go/src/github.com/tinygo-org/tinygo/
    57  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/tools /go/src/github.com/tinygo-org/tinygo/tools
    58  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/lib /go/src/github.com/tinygo-org/tinygo/lib
    59  
    60  RUN cd /go/src/github.com/tinygo-org/tinygo/ && \
    61      apt-get update && \
    62      apt-get install -y apt-utils python3 make clang-8 && \
    63      make gen-device-nrf && make gen-device-stm32 && \
    64      apt-get remove -y python3 make && \
    65      apt-get autoremove -y && \
    66      apt-get clean
    67  
    68  # tinygo-all stage installs the needed dependencies to compile TinyGo programs for all platforms.
    69  FROM tinygo-wasm AS tinygo-all
    70  
    71  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/Makefile /go/src/github.com/tinygo-org/tinygo/
    72  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/tools /go/src/github.com/tinygo-org/tinygo/tools
    73  COPY --from=tinygo-base /go/src/github.com/tinygo-org/tinygo/lib /go/src/github.com/tinygo-org/tinygo/lib
    74  
    75  RUN cd /go/src/github.com/tinygo-org/tinygo/ && \
    76      apt-get update && \
    77      apt-get install -y apt-utils python3 make clang-8 binutils-avr gcc-avr avr-libc && \
    78      make gen-device && \
    79      apt-get remove -y python3 make && \
    80      apt-get autoremove -y && \
    81      apt-get clean
    82  
    83  CMD ["tinygo"]