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

Fixing build regression [PATHS] #887

Merged
merged 2 commits into from
Dec 26, 2023
Merged

Conversation

seanmorris
Copy link
Contributor

@seanmorris seanmorris commented Dec 20, 2023

What is this PR doing?

This corrects some paths in the docker file used to copy libraries into the build image.

What problem is it solving?

Newer versions of Docker will ignore leading ../ that lead outside of the build context, but older versions will throw an error in that case.

How is the problem addressed?

This removes the extra ../ at the start of the paths in question. Newer versions of docker will ignore ../s that lead outside of the build context, but older versions will throw an error. The following paths will work on later versions but fail on earlier ones:

# Bring in the libraries
RUN mkdir -p /root/lib/include /root/lib/lib /libs
COPY ../../../../../../../../../../bison2.7/dist/ /libs/bison2.7
COPY ../../../../../../../../../../libedit/dist/root/lib /root/lib
COPY ../../../../../../../../../../libiconv/dist/root/lib /root/lib
COPY ../../../../../../../../../../libncurses/dist/root/lib /root/lib
COPY ../../../../../../../../../../libopenssl/dist/root/lib /root/lib
COPY ../../../../../../../../../../libpng16/dist/root/lib /root/lib
COPY ../../../../../../../../../../libsqlite3/dist/root/lib /root/lib
COPY ../../../../../../../../../../libxml2/dist/root/lib /root/lib
COPY ../../../../../../../../../../libz/dist/root/lib /root/lib
COPY ../../../../../../../../../../libzip/dist/1.2.0/root/lib /libs/libzip/1.2.0
COPY ../../../../../../../../../../libzip/dist/1.9.2/root/lib /libs/libzip/1.9.2
COPY ../../../../../../../../../../oniguruma/dist/root/lib /root/lib

Testing Instructions

Checkout the branch and pull dependencies:

git checkout sm-correcting-build-paths
npm install

Build the libraries:

cd packages/php-wasm/compile
make clean
make all

In a new terminal, build PHP 7.4 - 8.3: (PHP <=7.3 is fixed in #871)

npm run recompile:php:web:light:8.3
npm run recompile:php:web:light:8.2
npm run recompile:php:web:light:8.1
npm run recompile:php:web:light:8.0
npm run recompile:php:web:light:7.4
npm run recompile:php:web:kitchen-sink:8.3
npm run recompile:php:web:kitchen-sink:8.2
npm run recompile:php:web:kitchen-sink:8.1
npm run recompile:php:web:kitchen-sink:8.0
npm run recompile:php:web:kitchen-sink:7.4
npm run recompile:php:node:8.3
npm run recompile:php:node:8.2
npm run recompile:php:node:8.1
npm run recompile:php:node:8.0
npm run recompile:php:node:7.4

Ensure the build works:

npm run build
npm run dev

Navigate to the following URLs:

@seanmorris seanmorris changed the title Fixing build regression [Part II] Fixing build regression [Part I] Dec 20, 2023
@seanmorris seanmorris requested a review from adamziel December 20, 2023 04:49
@adamziel
Copy link
Collaborator

To reiterate my question from #871 (comment):

Are there any other Dockerfiles where the same issue needs to be fixed?

@seanmorris
Copy link
Contributor Author

seanmorris commented Dec 21, 2023

To reiterate my question from #871 (comment):

Are there any other Dockerfiles where the same issue needs to be fixed?

I found a couple. Fixed em:

COPY ./libncurses/dist/root/lib/include /root/lib/include
COPY ./libncurses/dist/root/lib/lib /root/lib/lib

COPY ./libz/dist/root/lib/include /root/lib/include
COPY ./libz/dist/root/lib/lib /root/lib/lib

COPY ./libz/dist/root/lib/include /root/lib/include
COPY ./libz/dist/root/lib/lib /root/lib/lib

COPY ./libz/dist/root/lib/include /root/lib/include
COPY ./libz/dist/root/lib/lib /root/lib/lib

COPY ./libz/dist/root/lib/include /root/lib/include
COPY ./libz/dist/root/lib/lib /root/lib/lib

COPY ./libz/dist/root/lib/include /root/lib/include
COPY ./libz/dist/root/lib/lib /root/lib/lib

@adamziel
Copy link
Collaborator

adamziel commented Dec 21, 2023

@seanmorris nice! Just to make sure – did you confirm the fix works? I see the testing instructions don't mention any make commands.

@seanmorris
Copy link
Contributor Author

@seanmorris nice! Just to make sure – did you confirm the fix works? I see the testing instructions don't mention any make commands.

I guess I assumed that it was handled by nx or a downstream script. I was using that during development and I've added that to the testing steps.

@seanmorris seanmorris changed the title Fixing build regression [Part I] Fixing build regression [PATHS] Dec 22, 2023
@seanmorris seanmorris self-assigned this Dec 22, 2023
@seanmorris
Copy link
Contributor Author

@seanmorris nice! Just to make sure – did you confirm the fix works? I see the testing instructions don't mention any make commands.

@adamziel This just inspired a much simpler fix for the Bison regression: #892

@seanmorris seanmorris added [Type] Bug An existing feature does not function as intended [Feature] PHP.wasm labels Dec 22, 2023
@dmsnell
Copy link
Member

dmsnell commented Dec 25, 2023

It sounds like we made a mistake earlier when creating this Dockerfile by referencing files outside of the directory in which we built the image. Is that right? And this fix is updating those paths so that they properly refer to the base directory itself?

And the reason we didn't notice this before is because older Docker versions normalize the path as if the root directory were the CWD in which the image is built, so that ../ accidentally worked since it was already "at the top" of the directory hierarchy. Is this correct?

If so, it seems like this is more of a universal fix and should work in all versions of Docker.

Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran a check for COPY ../ and found no more references than those listed here.

@seanmorris
Copy link
Contributor Author

It sounds like we made a mistake earlier when creating this Dockerfile by referencing files outside of the directory in which we built the image. Is that right? And this fix is updating those paths so that they properly refer to the base directory itself?

And the reason we didn't notice this before is because older Docker versions normalize the path as if the root directory were the CWD in which the image is built, so that ../ accidentally worked since it was already "at the top" of the directory hierarchy. Is this correct?

If so, it seems like this is more of a universal fix and should work in all versions of Docker.

I'm not entirely sure how we ended up in this situation. It could have been files that were moved from one place to another, paths that were updated erroneously, or any number of other small oversights. I can pour over the git history if need be, but in the end, it was the fact that newer versions of Docker will ignore the leading ../es if they lead outside the build context.

@seanmorris seanmorris merged commit 7c05925 into trunk Dec 26, 2023
5 checks passed
@seanmorris seanmorris deleted the sm-correcting-build-paths branch December 26, 2023 17:40
@dmsnell
Copy link
Member

dmsnell commented Dec 26, 2023

Thanks for merging. My question mostly was about the PR and commit descriptions, since this particularly issue doesn't seem so much like a Docker compatibility issue but rather a fix to a mistake we made in the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] PHP.wasm [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants