
This reduces the size of the Docker image from 13GB to 1.71GB, and should therefore make CI of the drivers package much faster. It should hopefully also avoid the out-of-space problem we currently have when building the smoke tests for the drivers repo. This size reduction is done by using multistage builds and only copying the necessary files in the final stage.
43 строки
1,1 КиБ
Docker
43 строки
1,1 КиБ
Docker
# 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-build stage builds the compiler itself
|
|
FROM tinygo-llvm-build AS tinygo-compiler-build
|
|
|
|
COPY . /tinygo
|
|
|
|
# build the compiler and tools
|
|
RUN cd /tinygo/ && \
|
|
git submodule update --init --recursive && \
|
|
make gen-device -j4 && \
|
|
make build/release
|
|
|
|
# tinygo-compiler copies the compiler build over to a base Go container (without
|
|
# all the build tools etc).
|
|
FROM golang:1.21 AS tinygo-compiler
|
|
|
|
# Copy tinygo build.
|
|
COPY --from=tinygo-compiler-build /tinygo/build/release/tinygo /tinygo
|
|
|
|
# Configure the container.
|
|
ENV PATH="${PATH}:/tinygo/bin"
|
|
CMD ["tinygo"]
|