Skip to content

Commit 140ebc9

Browse files
Add --force-rm flag (#9727)
* feat: add `--force-rm` flag to configure removing intermediate docker layers This commit makes it possible to turn off the removal of intermediate docker layers when building the tfb containers by adding a `--force-rm` flag to the tfb script. This is useful in situations where you want to inspect the intermediate layers for debugging purposes, or for caching builds of dependencies as a docker layer to speed up the build process. Note that the default behavior is to remove the intermediate layers to avoid filling up the disk with unused layers on the citrine server. Fixes: #9718 * hyper: cache dependencies to reduce build time This change reduces the time it takes to build the hyper Docker image by caching the dependency builds. This is done by building a dummy binary before copying the source code into the image. * Change default for --force-rm to False --------- Co-authored-by: Mike Smith <[email protected]>
1 parent f4188f0 commit 140ebc9

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
FROM rust:1.85 AS hyper
22

33
WORKDIR /src
4-
COPY . .
5-
RUN RUSTFLAGS="-C target-cpu=native" cargo install --path . --locked
4+
ENV RUSTFLAGS="-C target-cpu=native"
5+
6+
# Cache dependency builds (requires passing --force-rm False to tfb command)
7+
COPY Cargo.toml Cargo.lock /src/
8+
RUN mkdir src \
9+
&& echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs \
10+
&& cargo build --release \
11+
&& rm -rfv src/ target/release/hyper-techempower* target/release/deps/hyper_techempower*
12+
13+
COPY . /src/
14+
RUN cargo install --path . --locked
615
EXPOSE 8080
716
CMD ["hyper-techempower"]
817
HEALTHCHECK CMD curl --fail http://localhost:8080/ping || exit 1

toolset/run-tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def main(argv=None):
208208
nargs='*',
209209
default=None,
210210
help='Extra docker arguments to be passed to the test container')
211+
parser.add_argument(
212+
'--force-rm',
213+
default=False,
214+
help='Remove intermediate docker containers after running.')
211215

212216
# Network options
213217
parser.add_argument(

toolset/utils/benchmark_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(self, args):
5757
self.cpuset_cpus = args.cpuset_cpus
5858
self.test_container_memory = args.test_container_memory
5959
self.extra_docker_runtime_args = args.extra_docker_runtime_args
60+
self.force_rm_intermediate_docker_layers = args.force_rm
6061

6162
if self.network_mode is None:
6263
self.network = 'tfb'

toolset/utils/docker_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __build(self, base_url, path, build_log_file, log_prefix, dockerfile,
3939
path=path,
4040
dockerfile=dockerfile,
4141
tag=tag,
42-
forcerm=True,
42+
forcerm=self.benchmarker.config.force_rm_intermediate_docker_layers,
4343
timeout=3600,
4444
pull=True,
4545
buildargs=buildargs,

0 commit comments

Comments
 (0)