Dockerfile: reduce size of resulting image
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.
Этот коммит содержится в:
родитель
a2588d8db3
коммит
c47f52b546
1 изменённых файлов: 14 добавлений и 16 удалений
30
Dockerfile
30
Dockerfile
|
@ -20,26 +20,24 @@ 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
|
||||
# tinygo-compiler-build stage builds the compiler itself
|
||||
FROM tinygo-llvm-build AS tinygo-compiler-build
|
||||
|
||||
COPY . /tinygo
|
||||
|
||||
# update submodules
|
||||
# build the compiler and tools
|
||||
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 && \
|
||||
git submodule update --init --recursive && \
|
||||
make gen-device -j4 && \
|
||||
cp build/* $GOPATH/bin/
|
||||
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"]
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче