Skip to content

Commit

Permalink
Internal: debuggging dockerfile cache misses (#1557)
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvans authored Jan 3, 2024
1 parent a1a691f commit 68c07b9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ FROM centos7-build-golang-base AS centos7-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -180,6 +184,7 @@ FROM scratch AS centos7
COPY --from=centos7-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-centos-7.tgz
COPY --from=centos7-build /google-cloud-ops-agent*.rpm /


# ======================================
# Build Ops Agent for centos-8
# ======================================
Expand Down Expand Up @@ -265,6 +270,10 @@ FROM centos8-build-golang-base AS centos8-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -283,6 +292,7 @@ FROM scratch AS centos8
COPY --from=centos8-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-centos-8.tgz
COPY --from=centos8-build /google-cloud-ops-agent*.rpm /


# ======================================
# Build Ops Agent for rockylinux-9
# ======================================
Expand Down Expand Up @@ -371,6 +381,10 @@ FROM rockylinux9-build-golang-base AS rockylinux9-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -389,6 +403,7 @@ FROM scratch AS rockylinux9
COPY --from=rockylinux9-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-rockylinux-9.tgz
COPY --from=rockylinux9-build /google-cloud-ops-agent*.rpm /


# ======================================
# Build Ops Agent for debian-bookworm
# ======================================
Expand Down Expand Up @@ -472,6 +487,10 @@ FROM bookworm-build-golang-base AS bookworm-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -490,6 +509,7 @@ FROM scratch AS bookworm
COPY --from=bookworm-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-debian-bookworm.tgz
COPY --from=bookworm-build /google-cloud-ops-agent*.deb /


# ======================================
# Build Ops Agent for debian-bullseye
# ======================================
Expand Down Expand Up @@ -573,6 +593,10 @@ FROM bullseye-build-golang-base AS bullseye-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -591,6 +615,7 @@ FROM scratch AS bullseye
COPY --from=bullseye-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-debian-bullseye.tgz
COPY --from=bullseye-build /google-cloud-ops-agent*.deb /


# ======================================
# Build Ops Agent for debian-buster
# ======================================
Expand Down Expand Up @@ -676,6 +701,10 @@ FROM buster-build-golang-base AS buster-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -694,6 +723,7 @@ FROM scratch AS buster
COPY --from=buster-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-debian-buster.tgz
COPY --from=buster-build /google-cloud-ops-agent*.deb /


# ======================================
# Build Ops Agent for sles-12
# ======================================
Expand Down Expand Up @@ -796,6 +826,10 @@ FROM sles12-build-golang-base AS sles12-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -814,6 +848,7 @@ FROM scratch AS sles12
COPY --from=sles12-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-sles-12.tgz
COPY --from=sles12-build /google-cloud-ops-agent*.rpm /


# ======================================
# Build Ops Agent for sles-15
# ======================================
Expand Down Expand Up @@ -902,6 +937,10 @@ FROM sles15-build-golang-base AS sles15-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -920,6 +959,7 @@ FROM scratch AS sles15
COPY --from=sles15-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-sles-15.tgz
COPY --from=sles15-build /google-cloud-ops-agent*.rpm /


# ======================================
# Build Ops Agent for ubuntu-focal
# ======================================
Expand Down Expand Up @@ -1003,6 +1043,10 @@ FROM focal-build-golang-base AS focal-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -1021,6 +1065,7 @@ FROM scratch AS focal
COPY --from=focal-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-ubuntu-focal.tgz
COPY --from=focal-build /google-cloud-ops-agent*.deb /


# ======================================
# Build Ops Agent for ubuntu-jammy
# ======================================
Expand Down Expand Up @@ -1104,6 +1149,10 @@ FROM jammy-build-golang-base AS jammy-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -1122,6 +1171,7 @@ FROM scratch AS jammy
COPY --from=jammy-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-ubuntu-jammy.tgz
COPY --from=jammy-build /google-cloud-ops-agent*.deb /


# ======================================
# Build Ops Agent for ubuntu-lunar
# ======================================
Expand Down Expand Up @@ -1205,6 +1255,10 @@ FROM lunar-build-golang-base AS lunar-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -1223,6 +1277,7 @@ FROM scratch AS lunar
COPY --from=lunar-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-ubuntu-lunar.tgz
COPY --from=lunar-build /google-cloud-ops-agent*.deb /


# ======================================
# Build Ops Agent for ubuntu-mantic
# ======================================
Expand Down Expand Up @@ -1306,6 +1361,10 @@ FROM mantic-build-golang-base AS mantic-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -1324,6 +1383,7 @@ FROM scratch AS mantic
COPY --from=mantic-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-ubuntu-mantic.tgz
COPY --from=mantic-build /google-cloud-ops-agent*.deb /


FROM scratch
COPY --from=centos7 /* /
COPY --from=centos8 /* /
Expand Down
6 changes: 5 additions & 1 deletion dockerfiles/template
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ FROM {target_name}-build-golang-base AS {target_name}-build
WORKDIR /work
COPY . /work

# Debug why we get docker cache misses for release builds.
RUN go install github.com/MShekow/directory-checksum@main
RUN ${HOME}/go/bin/directory-checksum --max-depth=3 /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand All @@ -93,4 +97,4 @@ COPY --from={target_name}-build-wrapper /work/cache /work/cache

FROM scratch AS {target_name}
COPY --from={target_name}-build /tmp/google-cloud-ops-agent.tgz /google-cloud-ops-agent-{tar_distro_name}.tgz
COPY --from={target_name}-build /google-cloud-ops-agent*.{package_extension} /
COPY --from={target_name}-build /google-cloud-ops-agent*.{package_extension} /

0 comments on commit 68c07b9

Please sign in to comment.