Skip to content

Commit 0110166

Browse files
mochaaPhsudhof
authored andcommitted
GitHub PR#289 Use a seperate layer for final published docker image
-- 7571b3c by Zephyr Lykos <[email protected]>: Use a seperate layer for final published docker image Shaves off about 1.5G for the image size. Signed-off-by: Zephyr Lykos <[email protected]> Closes #289 GitOrigin-RevId: 91b1ae5 Change-Id: I4227e78a611b5a49a983fc6cbe04a820c41b8cf7
1 parent 6186b21 commit 0110166

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*Dockerfile

Dockerfile

+19-18
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,35 @@ ARG BAZEL_VERSION=:7.1.0
1616

1717
# Set up buildtools required
1818
FROM golang:latest AS buildtools
19-
RUN go install github.com/bazelbuild/buildtools/buildozer@latest
20-
RUN go install github.com/bazelbuild/buildtools/buildifier@latest
21-
19+
RUN go install github.com/bazelbuild/buildtools/buildozer@latest github.com/bazelbuild/buildtools/buildifier@latest
2220

2321
# Set up bazel env
2422
FROM gcr.io/bazel-public/bazel${BAZEL_VERSION} AS build
25-
WORKDIR .
26-
USER root
2723

28-
COPY --chown=ubuntu:root . .
29-
RUN apt-get update --fix-missing
30-
RUN apt-get install -y openjdk-17-jdk openjdk-17-jre git locales mercurial lsb-release software-properties-common quilt
31-
RUN add-apt-repository ppa:git-core/ppa -y
32-
RUN apt-get install -y git
33-
RUN apt-get update
24+
USER root
25+
RUN apt-get update && \
26+
apt-get install --no-install-recommends -y openjdk-17-jdk-headless && \
27+
rm -rf /var/lib/apt/lists/*
3428

35-
# cleanup apt cache afterwards to keep image size small
36-
RUN rm -rf /var/lib/apt/lists/*
3729
# Bazel does not allow running as root
3830
USER ubuntu
31+
32+
WORKDIR /home/ubuntu/
33+
COPY . .
34+
3935
RUN bazel build //java/com/google/copybara:copybara_deploy.jar --java_language_version=11 --tool_java_language_version=11 --java_runtime_version=remotejdk_11
40-
USER root
41-
RUN mkdir -p /opt/copybara && cp /home/ubuntu/bazel-bin/java/com/google/copybara/copybara_deploy.jar /opt/copybara/copybara_deploy.jar -r
42-
COPY --from=buildtools /go/bin/buildozer /go/bin/buildifier /usr/bin/
43-
USER ubuntu
4436

37+
# Use jammy to drop Python 2
38+
FROM docker.io/eclipse-temurin:17-jre-jammy
39+
40+
RUN apt-get update && \
41+
apt-get install --no-install-recommends -y git mercurial quilt && \
42+
rm -rf /var/lib/apt/lists/*
43+
44+
COPY --from=buildtools /go/bin/buildozer /go/bin/buildifier /usr/local/bin/
45+
COPY --from=build /home/ubuntu/bazel-bin/java/com/google/copybara/copybara_deploy.jar /opt/copybara/copybara_deploy.jar
4546
COPY .docker/copybara /usr/local/bin/copybara
47+
4648
ENTRYPOINT ["/usr/local/bin/copybara"]
4749
CMD ["migrate", "copy.bara.sky"]
4850
WORKDIR /usr/src/app
49-

0 commit comments

Comments
 (0)