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

Build php 5.3 using docker #1

Merged
merged 8 commits into from
Jan 4, 2021
Merged

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Dec 31, 2020

Implements the idea of moving build process to docker image:

this way can develop this locally without needing an appropriate VM. and not even Linux (macOS).

The build can be performed locally with:

docker build . -f php-5.3/Dockerfile -t php-5.3

refs:

@glensc
Copy link
Contributor Author

glensc commented Dec 31, 2020

This is a dirty changeset to show how it could be done.

Ideally, the build flow should be optimized so that individual steps could be cached and executed in parallel. For example building PHP extensions do not need to be sequential but could be parallel build. A parallel build is offered by docker buildkit if stages have no dependencies.

@glensc
Copy link
Contributor Author

glensc commented Dec 31, 2020

By default, the build output is too long:

 => => # [output clipped, log limit 1MiB reached]

The log could be directed to a file, or limit disabled:

@shivammathur
Copy link
Owner

I had put this together in the little time I had yesterday, so the scripts surely can be polished.
Yes ideally different sapi, extensions and libraries which are compiled in the build can be moved to a parallel jobs and cached. If you have time this week or next, it would be great if you could work on improving this.

For docker I think you can use this action in a separate workflow in the CI to test the Dockerfile. It supports buildx and caching the layers.

glensc added a commit to glensc/php5-ubuntu that referenced this pull request Dec 31, 2020
@glensc
Copy link
Contributor Author

glensc commented Dec 31, 2020

If needing actions, I think this action is fancier:

but currently, there's no such need, the docker build command works in the default setup.

@glensc
Copy link
Contributor Author

glensc commented Dec 31, 2020

Looks like GHA having temporary issues?

Run actions/checkout@v2
/usr/bin/docker exec  f517adb842589e0665ff8cd3e20dc78986a2eb4727add5179664d1c50dd9f81f sh -c "cat /etc/*release | grep ^ID"
/__e/node12/bin/node: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /__e/node12/bin/node)
/__e/node12/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.16' not found (required by /__e/node12/bin/node)
/__e/node12/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.17' not found (required by /__e/node12/bin/node)

this can't be my doing, as it fails before my jobs are executed, right?

@glensc glensc closed this Dec 31, 2020
@glensc glensc reopened this Dec 31, 2020
@glensc
Copy link
Contributor Author

glensc commented Dec 31, 2020

or the failure is due to missing eglibc?

	&& curl -o /tmp/libc.deb -sL http://archive.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6_2.19-0ubuntu6_amd64.deb \
	&& dpkg -i /tmp/libc.deb \

@shivammathur
Copy link
Owner

Nodejs build used in GitHub Action needs libstdc++6-4.7-dev and libc6_2.19 on ubuntu precise.

libstdc++6-4.7-dev can be sourced from this ppa ppa:ubuntu-toolchain-r/test

@glensc
Copy link
Contributor Author

glensc commented Dec 31, 2020

Argh, dropped the nodejs patching (5cb51df), it's no longer needed, it builds now:

can check after 20m, unless it fails sooner ;)

glensc added a commit to glensc/php5-ubuntu that referenced this pull request Dec 31, 2020
@glensc
Copy link
Contributor Author

glensc commented Jan 3, 2021

PLEASE do not force push, especially if PR is in WIP. I can't even figure out what your changes were to preserve them.

@glensc
Copy link
Contributor Author

glensc commented Jan 3, 2021

Noticed flaw in the current process: the built php53.tar is uploaded to the final filename before it's tested in CI.

@glensc
Copy link
Contributor Author

glensc commented Jan 3, 2021

@shivammathur here's build that passed (17m 23s):

it has no docker build optimization, everything is built serialized as before.

parallelization I planned to submit as separate PR after this is merged to keep the changes small and reviewable.

@glensc glensc mentioned this pull request Jan 3, 2021
glensc added a commit to glensc/php5-ubuntu that referenced this pull request Jan 3, 2021
@shivammathur
Copy link
Owner

shivammathur commented Jan 3, 2021

Sorry for the trouble, I have merged PR #2.
You can move the code to upload php53.tar.gz file to bintray after checks in the build53 workflow.

@glensc
Copy link
Contributor Author

glensc commented Jan 4, 2021

@glensc glensc marked this pull request as ready for review January 4, 2021 10:49
@shivammathur shivammathur merged commit 77d785d into shivammathur:master Jan 4, 2021
@glensc glensc deleted the docker-build branch January 4, 2021 12:10
@shivammathur
Copy link
Owner

@glensc Thanks for improving this. Great work!

@glensc
Copy link
Contributor Author

glensc commented Jan 4, 2021

IMHO this project should:

  1. build 5.4, 5.5, 5.6 similar manner with php-build, in the end maybe all php versions?
  2. build all external dependencies static, no shared libraries, this makes the php build relocatable, without dependencies like libicu.so, libssl.so. or keep the shared libs, but hardcode to /usr/local/php/lib.

this would provide a consistent process for all versions, currently, the workflow is really weird, really hard to grasp. some files committed to repo, some files built, some files downloaded. also, there's some weird tar+unpack+tar+unpack in the process which could be eliminated if things are straight forward. also, multiple compression formats for no apparent reasons. also build process does install steps (like enabling fpm service), sudo in places not needed, probably tons of leftovers from whatever the build was copied from.

I'm sure you're all aware of this and it takes time and efforts to improve this.

@shivammathur
Copy link
Owner

@glensc

I have thought about your suggestions and I agree that we also should build PHP 5.4 and PHP 5.5. Then we can incorporate patches for known bugs as well.

As for other PHP versions, I maintain php-builder. Currently it builds PHP 8.0 and master. May be I can add PHP 7.x builds there and PHP 5.6 build here once required (ppa:ondrej drops support for them).

Building already available libraries packages will add to maintenance and build time. So, better would be to keep shared libs and ship them with builds, and change the prefix of PHP to/usr as that would simplify scripts a lot as well. Not sure php-build supports different prefix and DESTDIR though. If not, this should be an easy patch upstream.

I would be able to give this time only next month or after. Before that, If you have time to implement this for PHP 5.4 and 5.5. I would be happy to test and merge.

@glensc
Copy link
Contributor Author

glensc commented Feb 5, 2021

@shivammathur I have been setting up the build for 5.5, I'll create WIP PR then for you to see. but I'm in the middle of splitting the job, so not everything is getting rebuilt if I change one file.

@glensc
Copy link
Contributor Author

glensc commented Feb 5, 2021

@shivammathur also, I think you should change your setup process from installing packages to enabling configs, i.e first the whole phpXY.tar is downloaded and unpacked, and then ini files are created or copied to enable extensions.

As I've noticed that versions that install .deb packages, are 3+ minutes long, but versions that use prebuilt php, take just seconds.

build time of base php images would not matter, as it's done only when there are fixes. and the docker cache layers will improve time if you want to develop things. for GHA docker image layers caching to work there's --cache-from option, but this requires publishing build result to docker registry, not sure this is wanted here.

See my similar project where all options are installed, but only enabling extensions with a simple script:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants