Skip to content

Commit

Permalink
docker: Dockerfile.builder: Optimize Dockerfile
Browse files Browse the repository at this point in the history
Separates the image into additional stages to leverage the cache.

The `tools/yosys/.gitcommit` file overwriting bypasses the
submodule check in its Makefile. This is done to avoid the
git-submodule files copying into the image, invalidating the build cache.

Signed-off-by: Illia Vysochyn <[email protected]>
  • Loading branch information
ivysochyn committed Jul 15, 2024
1 parent 74bf492 commit 22ba1e8
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions docker/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
# syntax=docker/dockerfile:1.7-labs

# Target with dependencies to build all flow tools from their sources.
# i.e., "./build_openroad.sh --local" from inside a docker container
# NOTE: don't use this file directly unless you know what you are doing,
# instead use etc/DockerHelper.sh

ARG fromImage=openroad/flow-ubuntu22.04-dev:latest

FROM $fromImage AS openroad-builder-base
FROM $fromImage AS orfs-base

ARG numThreads=$(nproc)

COPY . /OpenROAD-flow-scripts
WORKDIR /OpenROAD-flow-scripts
COPY --link dev_env.sh dev_env.sh
COPY --link build_openroad.sh build_openroad.sh
RUN ./build_openroad.sh --no_init --local --threads ${numThreads}

FROM $fromImage AS openroad-flow-scripts-base
FROM orfs-base AS orfs-builder-base
COPY . /OpenROAD-flow-scripts

RUN rm -rf /OpenROAD-flow-scripts/tools /OpenROAD-flow-scripts/.git

COPY --from=openroad-builder-base /OpenROAD-flow-scripts/tools/install /OpenROAD-flow-scripts/tools/install

FROM $fromImage
COPY --link tools tools
ARG numThreads=$(nproc)
COPY --from=openroad-flow-scripts-base /OpenROAD-flow-scripts /OpenROAD-flow-scripts
WORKDIR /OpenROAD-flow-scripts
RUN echo "" > tools/yosys/abc/.gitcommit && \
./build_openroad.sh --no_init --local --threads ${numThreads}

FROM orfs-base

COPY --link flow/platforms flow/platforms
COPY --link flow/designs flow/designs
COPY --link flow/tutorials flow/tutorials
COPY --link docs docs
COPY --link flow/util flow/util
COPY --link flow/scripts flow/scripts
COPY --link flow/test flow/test
COPY --link docker docker
COPY --link --from=orfs-builder-base /OpenROAD-flow-scripts/tools/install tools/install
COPY --link \
--exclude=.git* --exclude=tools/ --exclude=docs/ --exclude=docker/ \
--exclude=flow/designs --exclude=flow/platforms --exclude=flow/scripts \
--exclude=flow/test --exclude=flow/tutorials --exclude=flow/util \
. ./

0 comments on commit 22ba1e8

Please sign in to comment.