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

yiisoftware/yii2-php:7.4-fpm + mac m1 architecture #148

Closed
dsx90 opened this issue Apr 2, 2022 · 15 comments · Fixed by #161
Closed

yiisoftware/yii2-php:7.4-fpm + mac m1 architecture #148

dsx90 opened this issue Apr 2, 2022 · 15 comments · Fixed by #161

Comments

@dsx90
Copy link

dsx90 commented Apr 2, 2022

Can you build an image for the same architecture for m1 processors? In principle, I was able to rebuild locally by taking the original dockerfile and adding PHP_BASE_IMAGE_VERSION instead php:7.4.28-fpm@sha256:debf3848d5407dbdd45c2c01844f7ccc4e35902a0f6ff557dbc3e634b60e87e6 and getting a 10-fold increase in productivity. I think you will be able to do it more correctly.

@schmunk42
Copy link
Contributor

What is special about this image php:7.4.28-fpm@sha256:debf3848d5407dbdd45c2c01844f7ccc4e35902a0f6ff557dbc3e634b60e87e6 and where did you find the tag/hash?

@dsx90
Copy link
Author

dsx90 commented Apr 4, 2022

https://hub.docker.com/layers/php/library/php/7.4-fpm/images/sha256-debf3848d5407dbdd45c2c01844f7ccc4e35902a0f6ff557dbc3e634b60e87e6?context=explore
But the hash is not so mandatory it is demonstrated to indicate that there is an assembly for arm processors
#129
I also found this topic here and added a solution. I would be glad if you add it to the image. In my opinion, the image simply needs to be rebuilt with the updated php

@schmunk42
Copy link
Contributor

How can we build an image for a specific processor-arch with docker-compose?

Current build instruction: https://github.com/yiisoft/yii2-docker/blob/master/.github/workflows/docker-image.yml#L120

@dsx90
Copy link
Author

dsx90 commented Apr 6, 2022

Rebuild the image by pulling up the updated base images

@schmunk42
Copy link
Contributor

We're doing nightly builds: https://hub.docker.com/repository/docker/yiisoftware/yii2-php/tags?page=1&ordering=last_updated - so they should be the latest images.

@dsx90
Copy link
Author

dsx90 commented Apr 8, 2022

Then why here https://hub.docker.com/r/yiisoftware/yii2-php/tags only one OS/ARCH
linux/amd64 architecture is supported, although in the original image
https://hub.docker.com/layers/php/library/php/7.4-fpm/images/sha256-debf3848d5407dbdd45c2c01844f7ccc4e35902a0f6ff557dbc3e634b60e87e6?context=explore
there are about 8 of them

@schmunk42
Copy link
Contributor

I have no experience with multi-platform builds.

You can either specify that in the Dockerfile
https://docs.docker.com/engine/reference/builder/#from

Or docker-compose.yml
https://github.com/docker/docker.github.io/blob/master/compose/compose-file/compose-file-v2.md#platform

Which one would be needed (or both)?

Which platforms should we support? CC: @yiisoft/core-developers Might use much more build resources.

Can find m1 in the list:
Bildschirmfoto vom 2022-04-14 15-34-17

We also need to check if GitHub actions support other platforms.

PRs also in WIP welcome, I won't have much time for this.

@dsx90
Copy link
Author

dsx90 commented Apr 30, 2022

linux/arm64/v8

@lacek
Copy link

lacek commented Jul 11, 2022

multi-arch builds would be appreciated as yiisoftware/yii2-php:7.4-apache with SSL enabled won't run on M1 at the moment.

Prerequisite:

  • Install Docker for Desktop in MacOS running M1, or
  • Install multipass and launch a Ubuntu VM with docker:
    multipass launch docker
    multipass shell docker

Steps to reproduce:

mkdir web
echo 'It works!' > web/index.html


# test php:7.4-apache
docker run --name test_php -d -v $PWD/web:/var/www/html/ -p 8080:80 php:7.4-apache
curl http://localhost:8080
# It works!


# test php:7.4-apache with ssl module enabled
cat <<EOF > Dockerfile-php
FROM php:7.4-apache
RUN a2enmod ssl
EOF
docker build -t test_php_ssl -f Dockerfile-php .
docker run --name test_php_ssl -d -v $PWD/web:/var/www/html/ -p 8081:80 test_php_ssl
curl http://localhost:8081
# It works!


# test yiisoftware/yii2-php:7.4-apache
docker run --name test_yii2 -d -v $PWD/web:/app/web -p 8082:80 yiisoftware/yii2-php:7.4-apache
curl http://localhost:8082
# It works!


# test yiisoftware/yii2-php:7.4-apache with ssl module enabled
cat <<EOF > Dockerfile-yii2
FROM yiisoftware/yii2-php:7.4-apache
RUN a2enmod ssl
EOF
docker build -t test_yii2_ssl -f Dockerfile-yii2 .
docker run --name test_yii2_ssl -d -v $PWD/web:/app/web -p 8083:80 test_yii2_ssl
curl http://localhost:8083
# curl: (7) Failed to connect to localhost port 8083: Connection refused
docker logs test_yii2_ssl
# usermod: no changes
# AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
# [Mon Jul 11 13:41:02.758036 2022] [core:emerg] [pid 1] (95)Operation not supported: AH00023: Couldn't create the mpm-accept mutex
# (95)Operation not supported: could not create accept mutex
# AH00015: Unable to open logs


# clean up
docker rm -f test_php test_php_ssl test_yii2 test_yii2_ssl
docker rmi test_php_ssl test_yii2_ssl

@schmunk42
Copy link
Contributor

I'd recommend to add this to the docs: https://github.com/yiisoft/yii2-docker/tree/master/docs
Can you create a PR?

We're building with GitHub Actions, so we're bound to their infrastructure.

@zemkogabor
Copy link

Hello!

This is how I managed to build a custom php image for several architectures:

docker buildx build -t <your_registry>/php-custom:<version> . --platform=linux/arm64,linux/amd64 --push

Reference: https://github.com/zemkogabor/php-file-service#docker

We can use the same in the github action: https://blog.thesparktree.com/docker-multi-arch-github-actions
This will not work if the dockerfile contains some amd64 specific package.

@yepes
Copy link

yepes commented Jan 13, 2023

any updates on this?

@schmunk42
Copy link
Contributor

I couldn't figure out how to do that with GH-actions, PRs still welcome.

@zemkogabor
Copy link

My biggest problem with the arm64 build is that it's very slow on Github. Currently, Github does not have any arm64 architecture build servers. A possible workaround is to separate the builds into separate actions, so that the amd64 can be ready quickly, while the arm64 may take more than an hour to complete. Here's the example: AventailLtd/docker-php@14d4ed5

Returning to the PR. If I have a bit more time, I'll try to apply buildx to the Yii2 docker, if successful locally, I'll open a PR, but I can't promise anything at the moment.

@yepes
Copy link

yepes commented Jan 17, 2023

is it possible to do something on the client (developer) side to have this working? I don't have any experience on GH actions so can't help here

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 a pull request may close this issue.

5 participants