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

fix(multidim): make js-libp2p builds reproducible #288

Merged
merged 10 commits into from
Sep 7, 2023
2 changes: 1 addition & 1 deletion multidim-interop/impl/js/v0.46/BrowserDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM mcr.microsoft.com/playwright


COPY --from=js-libp2p-base /app/ /app/
WORKDIR /app/interop
WORKDIR /app/node_modules/@libp2p/multidim-interop
# We install browsers here instead of the cached version so that we use the latest browsers at run time.
# Ideally this would also be pinned, but playwright controls this, so there isn't much we can do about it.
# By installing here, we avoid installing it at test time.
Expand Down
10 changes: 5 additions & 5 deletions multidim-interop/impl/js/v0.46/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Here because we want to fetch the node_modules within docker so that it's
# installed on the same platform the test is run. Otherwise tools like `esbuild` will fail to run
FROM node:18
FROM node:18.17.1
WORKDIR /app
COPY . .
RUN npm i && npm run build
RUN apt-get update && apt-get install -y cmake
COPY package*.json ./
RUN npm ci

WORKDIR /app/interop
RUN npm i && npm run build
WORKDIR /app/node_modules/@libp2p/multidim-interop

ENTRYPOINT [ "npm", "run", "test:interop:multidim", "--", "--build", "false", "--types", "false", "-t", "node" ]
22 changes: 12 additions & 10 deletions multidim-interop/impl/js/v0.46/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
image_name := js-v0.46
commitSha := b7e608998cc88860d9ec8a3ed7c03fdfb3eccb3b
maschad marked this conversation as resolved.
Show resolved Hide resolved
image_name := js-v0.46.9

# TODO Enable webkit once https://github.com/libp2p/js-libp2p/pull/1627 is in
all: image.json chromium-image.json firefox-image.json
all: image.json chromium-image.json firefox-image.json update-lock-file

# Necessary because multistage builds require a docker image name rather than a digest to be used
load-image-json: image.json
Expand All @@ -18,17 +17,20 @@ firefox-image.json: load-image-json BrowserDockerfile
docker image inspect firefox-${image_name} -f "{{.Id}}" | \
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@

image.json: js-libp2p-${commitSha}
cd js-libp2p-${commitSha} && docker build -t ${image_name} -f ../Dockerfile .
# We update the lock file here so that we make sure we are always using the correct lock file.
# If this changes, CI will fail since there are unstaged changes.
update-lock-file: image.json
maschad marked this conversation as resolved.
Show resolved Hide resolved
CONTAINER_ID=$$(docker create $$(jq -r .imageID image.json)); \
docker cp $$CONTAINER_ID:/app/package-lock.json ./package-lock.json; \
docker rm $$CONTAINER_ID

image.json:
docker build -t ${image_name} -f ./Dockerfile .
docker image inspect ${image_name} -f "{{.Id}}" | \
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@

js-libp2p-${commitSha}:
wget -O js-libp2p-${commitSha}.zip "https://github.com/libp2p/js-libp2p/archive/${commitSha}.zip"
unzip -o js-libp2p-${commitSha}.zip
unzip -o js-libp2p-${commitSha}.zip

clean:
rm -rf image.json js-libp2p-*.zip js-libp2p-* *-image.json
rm -rf image.json *-image.json

.PHONY: all clean browser-images load-image-json
Loading