Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use docker image for build #473

Open
wants to merge 37 commits into
base: wasi-merge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
859942c
install curl
Dec 16, 2024
bcef3df
build everything with docker
Dec 16, 2024
78c4e86
docker build all PoC
Dec 16, 2024
729ed6e
updated README
Dec 16, 2024
81e0c31
readme improvements; comments
Dec 17, 2024
57bcd68
try the electricsql/pglite-builder docker image as ci docker image
Dec 17, 2024
c887fc3
Merge branch 'wasi-merge' into tudor/wasi-merge-docker
copiltembel Dec 17, 2024
1ca4b23
readd installing wasm and wasi sdk
Dec 17, 2024
4df2953
trying to fix the build
Dec 17, 2024
c63e902
add git to installed packages
Dec 17, 2024
a54ad45
still trying to fix the build
Dec 17, 2024
24c3259
we only need the electricsql/pglite-builder for building the wasm part
Dec 17, 2024
cae9c3f
Merge branch 'wasi-merge' into tudor/wasi-merge-docker
pmp-p Jan 13, 2025
3fd6776
Merge branch 'wasi-merge' into tudor/wasi-merge-docker
Jan 13, 2025
f65c697
install additional package inside docker container - ugly for now unt…
Jan 13, 2025
d41e7de
Merge branch 'wasi-merge' into tudor/wasi-merge-docker
Jan 13, 2025
267462a
update SDK_VERSION to 3.1.74.2bi
Jan 13, 2025
5b5c0f9
cleanup: remove allbuilder.dockerfile
Jan 13, 2025
2b7f05f
Merge branch 'wasi-merge' into tudor/wasi-merge-docker
Jan 14, 2025
b5f9d74
Merge branch 'wasi-merge' into tudor/wasi-merge-docker
Jan 14, 2025
3b8a4ef
change docker image for pglite-builder on CI
Jan 14, 2025
2dd7982
remove python wasm sdk extra
Jan 14, 2025
ed2f606
try build without using the CI variable
Jan 14, 2025
0f246ed
this seems to be needed
Jan 14, 2025
34c3c47
readd cleanup of previous build
Jan 14, 2025
531711f
pglite-prep cleanup
Jan 14, 2025
bcfa358
trying to fix CI build
Jan 14, 2025
482b946
revert to a previous state
Jan 14, 2025
1aebbd8
Merge branch 'tudor/wasi-merge-docker' of github.com:electric-sql/pgl…
Jan 14, 2025
5049e0b
revert changes
Jan 14, 2025
40483a9
cleanup
Jan 14, 2025
9fa2b29
retry removing some CI branches
Jan 14, 2025
5394f55
disable postgis on CI
Jan 14, 2025
22da5ed
update CMA_MB
Jan 14, 2025
e7776b4
change TOTAL_MEMORY to match the local build
Jan 14, 2025
c18d6e1
try without the packages
Jan 14, 2025
000ad90
readd the packages
Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ jobs:
build-and-test-pglite-dependents:
name: Build and Test packages dependent on PGlite
runs-on: ubuntu-22.04

needs: [build-and-test-pglite]
steps:
- uses: actions/checkout@v4
Expand Down
32 changes: 17 additions & 15 deletions .github/workflows/build_wasm_postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ jobs:
build:
name: Build WASM Postgres
runs-on: ubuntu-22.04
env:
BUILD_CONFIG_FILE: .buildconfig
SDK_ARCHIVE: python3.13-wasm-sdk-Ubuntu-22.04.tar.lz4
WASI_SDK_ARCHIVE: python3.13-wasi-sdk-Ubuntu-22.04.tar.lz4
SDKROOT: /opt/python-wasm-sdk
SYS_PYTHON: /usr/bin/python3
PGROOT: /tmp/pglite
TOTAL_MEMORY: 192MB
CMA_MB: 16
OBJDUMP: true
contrib: contrib
extra: extra
EXTRA_EXT: vector postgis
DEBUG: false
container:
image: electricsql/pglite-builder:REL_16_STABLE_3.1.74.2bi
env:
BUILD_CONFIG_FILE: .buildconfig
SDK_ARCHIVE: python3.13-wasm-sdk-Ubuntu-22.04.tar.lz4
WASI_SDK_ARCHIVE: python3.13-wasi-sdk-Ubuntu-22.04.tar.lz4
SDKROOT: /opt/python-wasm-sdk
SYS_PYTHON: /usr/bin/python3
PGROOT: /tmp/pglite
TOTAL_MEMORY: 128MB
CMA_MB: 64
OBJDUMP: true
contrib: contrib
extra: extra
EXTRA_EXT: vector
DEBUG: false

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -53,7 +55,7 @@ jobs:
if: steps.cache-restore.outputs.cache-hit != 'true'
working-directory: /
run: |
sudo apt-get install -y lz4 wget pv bash
apt update && apt-get install -y lz4 wget pv bash curl git build-essential libreadline-dev zlib1g-dev bison flex file
echo https://github.com/pygame-web/python-wasm-sdk/releases/download/$SDK_VERSION/$SDK_ARCHIVE
curl -sL --retry 5 https://github.com/pygame-web/python-wasm-sdk/releases/download/$SDK_VERSION/$SDK_ARCHIVE | tar xvP --use-compress-program=lz4 | pv -p -l -s 34500 >/dev/null
echo https://github.com/pygame-web/python-wasi-sdk/releases/download/$WASI_SDK_VERSION/$WASI_SDK_ARCHIVE
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,31 @@ pnpm changeset
```
And follow the instructions to create an appropriate changeset. Please ensure any contributions that touch code are accompanied by a changeset.

### Building everything with Docker

You can also build the PGlite from scratch by just issuing a docker build command:

`$ docker build -f buildall.dockerfile -t pglitedocker .`

This will build an image containing both the wasm and typescript parts of pglite.

You can then use this image, for example, to run the tests:

`$ docker run pglitedocker bash -c "cd /workspace/packages/pglite && pnpm test"`

#### Extract build artifacts from the docker image

Following is an example of how you can extract the build artifacts created in the previous step:

```
$ container_id=$(docker create pglitedocker)
$ docker cp "$container_id:/tmp/pglite/sdk" /tmp/
$ docker cp "$container_id:/tmp/web/postgres.wasm" /tmp/
$ docker rm "$container_id"
```

This will copy the sdk build artifacts folder as well as the postgres.wasm binary to your local /tmp folder

## Acknowledgments

PGlite builds on the work of [Stas Kelvich](https://github.com/kelvich) of [Neon](https://neon.tech) in this [Postgres fork](https://github.com/electric-sql/postgres-wasm).
Expand Down
26 changes: 26 additions & 0 deletions buildall.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG PG_VERSION=git
ARG SDK_VERSION=3.1.74.2bi
FROM electricsql/pglite-builder:${PG_VERSION}_${SDK_VERSION}

ENV NODE_VERSION=20.18.1
RUN apt update && apt install -y curl git build-essential libreadline-dev zlib1g-dev bison flex file
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version
RUN corepack enable pnpm

# RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -

WORKDIR /workspace

COPY . .

RUN pnpm install
# runs the wasm build without spinning yet another docker instance that would produce them
RUN pnpm wasm:build-no-docker
RUN pnpm ts:build
36 changes: 18 additions & 18 deletions cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,26 +419,26 @@ then

fi

if echo " $*"|grep -q " extra"
if echo " $*"|grep -q " extra"
then
for extra_ext in ${EXTRA_EXT:-"vector"}
do
if $CI
then
if [ -d $PREFIX/include/X11 ]
then
echo -n
else
# install EXTRA sdk
. /etc/lsb-release
DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}"
CIVER=${CIVER:-$DISTRIB}
SDK_URL=https://github.com/pygame-web/python-wasm-sdk-extra/releases/download/$SDK_VERSION/python3.13-emsdk-sdk-extra-${CIVER}.tar.lz4
echo "Installing $SDK_URL"
curl -sL --retry 5 $SDK_URL | tar xvP --use-compress-program=lz4 | pv -p -l -s 15000 >/dev/null
chmod +x ./extra/*.sh
fi
fi
# if $CI
# then
# if [ -d $PREFIX/include/X11 ]
# then
# echo -n
# else
# # install EXTRA sdk
# . /etc/lsb-release
# DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}"
# CIVER=${CIVER:-$DISTRIB}
# SDK_URL=https://github.com/pygame-web/python-wasm-sdk-extra/releases/download/$SDK_VERSION/python3.13-emsdk-sdk-extra-${CIVER}.tar.lz4
# echo "Installing $SDK_URL"
# curl -sL --retry 5 $SDK_URL | tar xvP --use-compress-program=lz4 | pv -p -l -s 15000 >/dev/null
# chmod +x ./extra/*.sh
# fi
# fi
echo "======================= ${extra_ext} : $(pwd) ==================="

./extra/${extra_ext}.sh || exit 400
Expand Down Expand Up @@ -590,7 +590,7 @@ ________________________________________________________________________________

pglite-prep) echo "==================== pglite-prep =========================="
mkdir -p $PGLITE/release
#rm $PGLITE/release/*
# rm -r $PGLITE/release/*

# copy packed extensions
cp -vf ${WEBROOT}/*.tar.gz ${PGLITE}/release/
Expand Down
5 changes: 5 additions & 0 deletions cibuild/build-all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash
echo "======== build-all.sh : $(pwd) =========="

echo "======== Installing packages =========="

apt update && apt install -y git bison flex

echo "======== Building all PGlite prerequisites =========="

# move copy of patches into dir
Expand Down
21 changes: 21 additions & 0 deletions cibuild/build-without-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
echo "======== build-without-docker.sh : $(pwd) =========="
echo "======== Building all PGlite prerequisites using Docker =========="

trap 'echo caught interrupt and exiting;' INT

source .buildconfig

if [[ -z "$SDK_VERSION" || -z "$PG_VERSION" ]]; then
echo "Missing SDK_VERSION and PG_VERSION env vars."
echo "Source them from .buildconfig"
exit 1
fi

export IMG_NAME="electricsql/pglite-builder"
export IMG_TAG="${PG_VERSION}_${SDK_VERSION}"
export SDK_ARCHIVE=python3.13-wasm-sdk-Ubuntu-22.04.tar.lz4
export WASI_SDK_ARCHIVE=python3.13-wasi-sdk-Ubuntu-22.04.tar.lz4
export OBJDUMP=${OBJDUMP:-true}

./cibuild/build-all.sh
15 changes: 8 additions & 7 deletions cibuild/pgbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ CC_PGLITE=$CC_PGLITE
export MAIN_MODULE=""
else
# --with-libxml does not fit with --without-zlib
if $CI
then
# do not build obsolete ext xml2 on CI
XML2="--with-zlib --with-libxml"
else
XML2="--with-zlib --with-libxml --with-libxslt"
fi
# if $CI
# then
# # do not build obsolete ext xml2 on CI
# XML2="--with-zlib --with-libxml"
# else
# XML2="--with-zlib --with-libxml --with-libxslt"
# fi
XML2="--with-zlib --with-libxml --with-libxslt"
UUID="--with-uuid=ossp"
BUILD=emscripten
WASM_CFLAGS=""
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"ci:publish": "pnpm changeset publish",
"build:all": "pnpm wasm:build && pnpm ts:build",
"ts:build": "pnpm -r --filter \"./packages/**\" build",
"wasm:build": "bash ./cibuild/build-with-docker.sh"
"wasm:build": "bash ./cibuild/build-with-docker.sh",
"wasm:build-no-docker": "bash ./cibuild/build-without-docker.sh",
"docker:buildpglite": "docker build -f buildall.dockerfile ."
},
"devDependencies": {
"@changesets/cli": "^2.27.9",
Expand Down
Loading