Skip to content

Commit

Permalink
Improve Docker build (#524)
Browse files Browse the repository at this point in the history
* Make Dockerfile friendlier to more build systems
* Patch install-sysroot.py
* Fix and hasten Docker Makefile
* Clarify Makefile.docker

---------

Co-authored-by: Andrew Brobston <400286+abrobston@users.noreply.github.com>
Co-authored-by: Jerry Sievert <code@legitimatesounding.com>
  • Loading branch information
3 people committed Apr 9, 2023
1 parent b410e8f commit 42471e1
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 25 deletions.
57 changes: 39 additions & 18 deletions Makefiles/Makefile.docker
Expand Up @@ -15,33 +15,54 @@ build/gn/out/gn:
@echo "Setting up build directory"
@mkdir -p build
@echo "Downloading gn source"
@git clone -q https://gn.googlesource.com/gn.git build/gn
@cd build/gn && git checkout -q eea3906f0e2a8d3622080127d2005ff214d51383
@mkdir -p build/gn && cd build/gn && git clone -q https://gn.googlesource.com/gn.git . && git checkout -q eea3906f0e2a8d3622080127d2005ff214d51383
@echo "Building gn"
@cd build/gn && python3 build/gen.py --no-static-libstdc++ && ninja -C out/ gn

build/v8: build/gn/out/gn
@echo "Downloading v8 source"
@git clone -q https://github.com/v8/v8 --branch 9.7.37 --single-branch build/v8
@cd build/v8 && git checkout -q 9.7.37
@git clone -q https://github.com/v8/v8 --branch 9.7.37 --single-branch --depth 1 build/v8
@echo "Patching v8 code"
@cd build/v8 && (git apply ../../patches/code/*.patch || true)
@echo "Downloading up third party sources"
@git clone -q https://chromium.googlesource.com/chromium/src/base/trace_event/common.git build/v8/base/trace_event/common
@cd build/v8/base/trace_event/common && git checkout -q 3da1e2fcf66acd5c7194497b4285ac163f32e239
@git clone -q https://chromium.googlesource.com/chromium/src/build.git build/v8/build
@cd build/v8/build && git checkout -q bbf7f0ed65548c4df862d2a2748e3a9b908a3217
@git clone -q https://chromium.googlesource.com/external/github.com/google/googletest.git build/v8/third_party/googletest/src
@cd build/v8/third_party/googletest/src && git checkout -q 47f819c3ca54fb602f432904443e00a0a1fe2f42
@git clone -q https://chromium.googlesource.com/chromium/deps/icu.git build/v8/third_party/icu
@cd build/v8/third_party/icu && git checkout -q 75e34bcccea0be165c31fdb278b3712c516c5876
@git clone -q https://chromium.googlesource.com/chromium/src/third_party/jinja2.git build/v8/third_party/jinja2
@cd build/v8/third_party/jinja2 && git checkout -q ee69aa00ee8536f61db6a451f3858745cf587de6
@git clone -q https://chromium.googlesource.com/chromium/src/third_party/markupsafe.git build/v8/third_party/markupsafe
@cd build/v8/third_party/markupsafe && git checkout -q 1b882ef6372b58bfd55a3285f37ed801be9137cd
@git clone -q https://chromium.googlesource.com/chromium/src/third_party/zlib.git build/v8/third_party/zlib
@cd build/v8/third_party/zlib && git checkout -q 563140dd9c24f84bf40919196e9e7666d351cc0d
@mkdir -p build/v8/base/trace_event/common
@cd build/v8/base/trace_event/common && git init -q .
@cd build/v8/base/trace_event/common && git remote add origin https://chromium.googlesource.com/chromium/src/base/trace_event/common.git
@cd build/v8/base/trace_event/common && git fetch -q --depth 1 origin 3da1e2fcf66acd5c7194497b4285ac163f32e239
@cd build/v8/base/trace_event/common && git reset -q --hard 3da1e2fcf66acd5c7194497b4285ac163f32e239
@mkdir -p build/v8/build
@cd build/v8/build && git init -q .
@cd build/v8/build && git remote add origin https://chromium.googlesource.com/chromium/src/build.git
@cd build/v8/build && git fetch -q --depth 1 origin bbf7f0ed65548c4df862d2a2748e3a9b908a3217
@cd build/v8/build && git reset -q --hard bbf7f0ed65548c4df862d2a2748e3a9b908a3217
@mkdir -p build/v8/third_party/googletest/src
@cd build/v8/third_party/googletest/src && git init -q .
@cd build/v8/third_party/googletest/src && git remote add origin https://chromium.googlesource.com/external/github.com/google/googletest.git
@cd build/v8/third_party/googletest/src && git fetch -q --depth 1 origin 47f819c3ca54fb602f432904443e00a0a1fe2f42
@cd build/v8/third_party/googletest/src && git reset -q --hard 47f819c3ca54fb602f432904443e00a0a1fe2f42
@mkdir -p build/v8/third_party/icu
@cd build/v8/third_party/icu && git init -q .
@cd build/v8/third_party/icu && git remote add origin https://chromium.googlesource.com/chromium/deps/icu.git
@cd build/v8/third_party/icu && git fetch -q --depth 1 origin 75e34bcccea0be165c31fdb278b3712c516c5876
@cd build/v8/third_party/icu && git reset -q --hard 75e34bcccea0be165c31fdb278b3712c516c5876
@mkdir -p build/v8/third_party/jinja2
@cd build/v8/third_party/jinja2 && git init -q .
@cd build/v8/third_party/jinja2 && git remote add origin https://chromium.googlesource.com/chromium/src/third_party/jinja2.git
@cd build/v8/third_party/jinja2 && git fetch -q --depth 1 origin ee69aa00ee8536f61db6a451f3858745cf587de6
@cd build/v8/third_party/jinja2 && git reset -q --hard ee69aa00ee8536f61db6a451f3858745cf587de6
@mkdir -p build/v8/third_party/markupsafe
@cd build/v8/third_party/markupsafe && git init -q .
@cd build/v8/third_party/markupsafe && git remote add origin https://chromium.googlesource.com/chromium/src/third_party/markupsafe.git
@cd build/v8/third_party/markupsafe && git fetch -q --depth 1 origin 1b882ef6372b58bfd55a3285f37ed801be9137cd
@cd build/v8/third_party/markupsafe && git reset -q --hard 1b882ef6372b58bfd55a3285f37ed801be9137cd
@mkdir -p build/v8/third_party/zlib
@cd build/v8/third_party/zlib && git init -q .
@cd build/v8/third_party/zlib && git remote add origin https://chromium.googlesource.com/chromium/src/third_party/zlib.git
@cd build/v8/third_party/zlib && git fetch -q --depth 1 origin 563140dd9c24f84bf40919196e9e7666d351cc0d
@cd build/v8/third_party/zlib && git reset -q --hard 563140dd9c24f84bf40919196e9e7666d351cc0d
@cp Makefiles/gclient_args.gni build/v8/build/config/gclient_args.gni
@echo "Patching sysroot scripts"
@cd build/v8/build && (git apply ../../../patches/sysroot/*.patch || true)
@echo "Setting up sysroot"
@cd build/v8 && python3 build/linux/sysroot_scripts/install-sysroot.py --arch=$(ARCH)
@echo "Generating v8 configuration"
Expand Down
13 changes: 13 additions & 0 deletions patches/sysroot/01-install-sysroot.patch
@@ -0,0 +1,13 @@
diff --git a/linux/sysroot_scripts/install-sysroot.py b/linux/sysroot_scripts/install-sysroot.py
index eaa1c2e..abd7eb4 100755
--- a/linux/sysroot_scripts/install-sysroot.py
+++ b/linux/sysroot_scripts/install-sysroot.py
@@ -155,7 +155,7 @@
if sha1sum != tarball_sha1sum:
raise Error('Tarball sha1sum is wrong.'
'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum))
- subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot])
+ subprocess.check_call(['tar', 'mxf', tarball, '-C', sysroot])
os.remove(tarball)

with open(stamp, 'w') as s:
13 changes: 13 additions & 0 deletions patches/sysroot/02-install-sysroot.patch
@@ -0,0 +1,13 @@
diff --git a/linux/sysroot_scripts/install-sysroot.py b/linux/sysroot_scripts/install-sysroot.py
index eaa1c2e..abd7eb4 100755
--- a/linux/sysroot_scripts/install-sysroot.py
+++ b/linux/sysroot_scripts/install-sysroot.py
@@ -155,7 +155,7 @@
if sha1sum != tarball_sha1sum:
raise Error('Tarball sha1sum is wrong.'
'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum))
- subprocess.check_call(['tar', 'mxf', tarball, '-C', sysroot])
+ subprocess.check_call(['tar', '--no-same-owner', '-mxf', tarball, '-C', sysroot])
os.remove(tarball)

with open(stamp, 'w') as s:
20 changes: 13 additions & 7 deletions platforms/Docker/bullseye/14.5/Dockerfile
@@ -1,21 +1,27 @@
FROM postgres:14.5-bullseye as builder
ARG PG_CONTAINER_VERSION=14.5
FROM docker.io/library/postgres:${PG_CONTAINER_VERSION}-bullseye as builder

ENV PLV8_VERSION=3.1.6
ENV PLV8_BRANCH=r3.1
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex \
&& apt-get update \
&& apt-get install -y build-essential curl python3 ninja-build git wget postgresql-server-dev-${PG_MAJOR} libtinfo5 pkg-config clang binutils \
&& git clone https://github.com/plv8/plv8 \
&& apt-get clean
ARG PLV8_BRANCH=r3.1
ENV PLV8_BRANCH=${PLV8_BRANCH}
ARG PLV8_VERSION=3.1.6
ENV PLV8_VERSION=${PLV8_VERSION}
RUN set -ex \
&& git clone --branch ${PLV8_BRANCH} --single-branch --depth 1 https://github.com/plv8/plv8 \
&& cd plv8 \
&& git checkout ${PLV8_BRANCH} \
&& make DOCKER=1 generate_upgrades \
&& make DOCKER=1 install \
&& strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so


FROM postgres:14.5-bullseye
FROM docker.io/library/postgres:${PG_CONTAINER_VERSION}-bullseye

ENV PLV8_VERSION=3.1.6
ARG PLV8_VERSION=3.1.6
ENV PLV8_VERSION=${PLV8_VERSION}
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/plv8* /usr/lib/postgresql/${PG_MAJOR}/lib/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/plv8-${PLV8_VERSION}.index.bc /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/plv8-${PLV8_VERSION}/* /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/plv8-${PLV8_VERSION}/
Expand Down

0 comments on commit 42471e1

Please sign in to comment.