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

Docker image improvements (CON-282) #138

Merged
merged 1 commit into from
Aug 28, 2023

Conversation

Diegorro98
Copy link
Contributor

@Diegorro98 Diegorro98 commented Dec 26, 2022

I created this workflow because I needed to create an image to perform an automated building for my project, so now I'm apporting the workflow to this repository.
The dockerfile is based on esp-idf docker images (v4.4.2 by default as it is the supported IDF version , but it can be changed with build args).

Also I created a readme file that contains info about the images and build args that can be used with the dockerfile. I wish I had more info about the docker image which tag is chip and its purpose in order to write it into the docs too, but I left some space for that here:

arm64 build has the problem that takes too long (between 2 and 4 hours) to setup the python environment when bootstrapping Matter and more than 1.5 hours building host tools. Here you can see a workflow that tried to build amd64 and arm64 image but it exceded the maximum execution time. That's why I disabled the arm64 build in the last commit.

You can test an amd64 image pulling from my docker hub: https://hub.docker.com/r/diegorro98/esp-matter/tags

Also fixes #89.

As mentioned at #89 (comment)), Maybe there is a WIP workflow on the internal repository or similar to create an image with the same purpose.

@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from 3a9a186 to 3c25eaf Compare January 7, 2023 11:51
@Diegorro98
Copy link
Contributor Author

Rebased to include python requirements

@shubhamdp
Copy link
Contributor

Hi @Diegorro98, yes we do have a work in progress on this for quite some time. I had Dockerfile and the workflow ready but we were still thinking about adding it to esp-matter.

As mentioned at #89 (comment)), Maybe there is a WIP workflow on the internal repository or similar to create an image with the same purpose.

But, looks like this is the high time that we add it. So, I have already put up an PR internally for the required changes.

My changes uses chip-build-esp32 docker image and yours uses the IDF base image.

I did not consider the IDF v5.0 case. May be we can merge our WIP changes and then you can rebase and put up the extra's that you have on top of it?

@shubhamdp
Copy link
Contributor

@Diegorro98 Thank you very much for contributing

@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Jan 11, 2023

Hi @shubhamdp, thank you for reviewing!
Okey, merge your WIP changes and then lets see what can I contribute to the docker file 😄
Out of curiosity, what is the reason behind using the chip-build-esp32 docker image?

@shubhamdp
Copy link
Contributor

@Diegorro98 We have merged the changes, please take a look. Dockerfile and Workflow

Reason for using chip-build-esp32 is that it already has all the stuff to setup esp-matter. It has IDF and all prerequisites required for connectedhomeip

@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from 3c25eaf to 5d51d05 Compare January 13, 2023 11:25
@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Jan 13, 2023

@shubhamdp I already added extra stuff like arguments, an entrypoint so it can be used easily with docker run and the doc about them.

About the IDF v5.0, I'm not sure how to implement it, I was thinking to use chip-build as base image and rewrite this Dockerfile from the chip-build-esp32 so we can give arguments and can be changed. What do you think about it?

I will do the changes and push them so the idea can be visualized. If the idea is discarded I will return revert the changes by undoing them and pushing.

@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch 2 times, most recently from 47f6824 to 10740a3 Compare January 14, 2023 10:27
@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Jan 14, 2023

I thought about other alternative which would copy from the esp-idf image the required files this way:

ARG ESP_IDF_TAG=v4.4.3
FROM espressif/idf:${ESP_IDF_TAG} as idf

ARG VERSION=latest
FROM connectedhomeip/chip-build:${VERSION}

ENV IDF_PATH=/opt/espressif/esp-idf/
ENV IDF_TOOLS_PATH=/opt/espressif/tools

COPY --from=idf /opt/esp/idf /opt/espressif/esp-idf

# Setup the ESP-IDF
WORKDIR /opt/espressif/esp-idf
RUN set -x \
    && ./install.sh \
    && : # last line

But It would lead to bigger image size (more or less 0.7 GB bigger), more processing time (2 min more, which might be irrelevant) and less control over esp-idf because ESP_IDF_TAG would be the only option vs the options that are pushed right now. The only benefit of this is code simplicity in the Dockerfile.

@Diegorro98 Diegorro98 changed the title Docker image for development Docker image improvements Jan 14, 2023
@shubhamdp
Copy link
Contributor

shubhamdp commented Jan 18, 2023

@Diegorro98 better would be that we use the IDF docker images and install connectedhomeip dependencies. shallow clone the esp-matter and run install.sh

Probably what you did earlier

@shubhamdp
Copy link
Contributor

Since, we are building it for multiple idf versions, we may have to modify the workflow to build it for both idf v5.0 and v4.4.3

We can use matrix for this.

@Diegorro98
Copy link
Contributor Author

@Diegorro98 better would be that we use the IDF docker images and install connectedhomeip dependencies. shallow clone the esp-matter and run install.sh

Probably what you did earlier

@shubhamdp okey, I'm gonna restore that in a new branch and I will post the link to the branch here so you can compare both solutions. I will also build and push the image result to the my esp-matter docker hub.

Since, we are building it for multiple idf versions, we may have to modify the workflow to build it for both idf v5.0 and v4.4.3

We can use matrix for this.

I can do that, no problem 😄

@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from 73d6d7c to 78a9b14 Compare January 18, 2023 22:49
@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Jan 19, 2023

https://github.com/Diegorro98/esp-matter/tree/feature/docker_image_alternative

This is the branch with what I did earlier with some changes.

Images from the actual changes in this pull request and the mentioned branch, each one with idf v4.4.3 and v5.0, are at my docker hub:
https://hub.docker.com/r/diegorro98/esp-matter/tags

@shubhamdp
Copy link
Contributor

Hi @Diegorro98 I have been working on supporting esp-idf v5.0, project-chip/connectedhomeip#24589. Once that gets merge, we will pull those changes into esp-matter and can take this up to build examples with both idf v4.4 and v5.0

@Diegorro98
Copy link
Contributor Author

Hi @shubhamdp, I have seen that in 2a7abbb you have changed from . to source to run the .sh files.
Should I update it here too?

@HomeACcessoryKid
Copy link

Can I comment that the images built by espressif are all tagged as latest.
It would be good to have a tag with the date, like if today, the tag would be 20230213.
Like that, we remember which image we are working on and more such advantages.
Hopefully this will be reflected in the upcoming images for 4.4.4 and 5.0
Thanks in advance!

@github-actions github-actions bot changed the title Docker image improvements Docker image improvements (CON-282) Feb 13, 2023
@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from 78a9b14 to 1d941d0 Compare April 5, 2023 10:21
@Diegorro98
Copy link
Contributor Author

Rebased in to include latest changes

@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Apr 13, 2023

@shubhamdp ESP-IDF 5.0/5.1 is already supported in current Matter commit right?
Should this PR be merged now? Or are you waiting for release tags to add them to this PR to close #267? or there is any other reason why this PR hasn't been merged yet?

@shubhamdp
Copy link
Contributor

@Diegorro98 I wanted to review this PR since last two weeks but couldn't do that. There are few changes that will be needed to get this merged, I'll review the PR this week and lets get this merged then.

@Diegorro98
Copy link
Contributor Author

@shubhamdp awesome! thank you for you answer :)

.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Apr 18, 2023

@shubhamdp Changes done! The image tag format will be esp-matter:latest(_idf(_branchOrTag)(_ref))
I also updated the version from v4.4.3 to v5.0.1, as readme.md in main specifies.

Copy link
Contributor

@shubhamdp shubhamdp left a comment

Choose a reason for hiding this comment

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

I'll give a try to these images on my fork of esp-matter to build examples as well.

.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
@darkxst
Copy link

darkxst commented Jul 17, 2023

Also need to pass in full SHA ref for the following command to work. It fails with abbreviated ref's.

git fetch origin --depth=1 --recurse-submodules ea5e0ff298e6257b31d8e0c81435e6d3937f04c7

@Diegorro98
Copy link
Contributor Author

@darkxst Also true, I really thought it worked because the build passed, but it passed because the checkout reference wasn't used due to the error you mentioned in last review. Thank you a lot for the feedback!

.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
tools/docker/matter-builds Outdated Show resolved Hide resolved
tools/docker/matter-builds Outdated Show resolved Hide resolved
tools/docker/matter-builds Outdated Show resolved Hide resolved
@Diegorro98
Copy link
Contributor Author

I've found that building docker files at GitHub Actions tends to file because of the space; I've also found that setting the following steps at the workflow frees enough space to be able to create the docker image:

jobs:
  build:
     steps:
        - run: sudo rm -rf /usr/share/dotnet
        - run: sudo rm -rf "$AGENT_TOOLSDIRECTORY"

@shubhamdp, what do you think? Should I add it?

@shubhamdp
Copy link
Contributor

I've found that building docker files at GitHub Actions tends to file because of the space; I've also found that setting the following steps at the workflow frees enough space to be able to create the docker image:

jobs:
  build:
     steps:
        - run: sudo rm -rf /usr/share/dotnet
        - run: sudo rm -rf "$AGENT_TOOLSDIRECTORY"

@shubhamdp, what do you think? Should I add it?

If this works then please add that.

Copy link
Contributor

@shubhamdp shubhamdp left a comment

Choose a reason for hiding this comment

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

@Diegorro98 Sorry for the delay and thanks for making this effort. I have few minor suggestion and we are good to merge this.

.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
tools/docker/matter-builds Outdated Show resolved Hide resolved
tools/docker/matter-builds Outdated Show resolved Hide resolved
.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from 30584fc to 0b6121e Compare August 23, 2023 18:15
@shubhamdp
Copy link
Contributor

shubhamdp commented Aug 24, 2023

@Diegorro98 Please stash squash the commits as well.

@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Aug 24, 2023

@shubhamdp sorry, what do you mean by "stash the commits"?

@shubhamdp
Copy link
Contributor

@Diegorro98 sorry, I meant squash.

@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from 4837b5c to 2a443fe Compare August 24, 2023 09:47
@Diegorro98
Copy link
Contributor Author

@shubhamdp is that okey?

tools/docker/matter-builds Outdated Show resolved Hide resolved
tools/docker/matter-builds Outdated Show resolved Hide resolved
.github/workflows/docker-image.yml Outdated Show resolved Hide resolved
@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from 2a443fe to c44d614 Compare August 25, 2023 09:51
@shubhamdp
Copy link
Contributor

@Diegorro98 Can you please rebase to latest main branch. I pushed these changes internally but failed.

@Diegorro98 Diegorro98 force-pushed the feature/docker_image branch from c44d614 to 3cef104 Compare August 25, 2023 10:51
@Diegorro98
Copy link
Contributor Author

@shubhamdp rebased!

@espressif-bot espressif-bot merged commit 08b277e into espressif:main Aug 28, 2023
@dhrishi
Copy link
Collaborator

dhrishi commented Aug 28, 2023

Thank you @Diegorro98 for your contribution and patience ;-) :-D

@Diegorro98
Copy link
Contributor Author

Diegorro98 commented Aug 28, 2023

@dhrishi no problem, glad to help! 😊

BTW, I've seen that the workflow didn't work
For some reason, GITHUB_REF_NAME is not valid at docker build and push action build arguments, it should be replaced to github.ref.
I added this fix in my fork to the main branch, but I forgot to add it to the PR.

Also I forgot to include a comment explaining these two steps I added to the workflow:

I've found that building docker files at GitHub Actions tends to file because of the space; I've also found that setting the following steps at the workflow frees enough space to be able to create the docker image:

jobs:
  build:
     steps:
        - run: sudo rm -rf /usr/share/dotnet
        - run: sudo rm -rf "$AGENT_TOOLSDIRECTORY"

@shubhamdp, what do you think? Should I add it?

Should I create a new PR including the fix and the comment?

@shubhamdp
Copy link
Contributor

shubhamdp commented Aug 28, 2023

@Diegorro98 Thanks for bringing it up. I've already raised a PR to fix this, along with few other relevant changes.

@shubhamdp
Copy link
Contributor

@Diegorro98 I've not added the comment though to my fixes, may be you can do that.

@Diegorro98
Copy link
Contributor Author

@shubhamdp sure! I'm going to create a new PR with the comment then.

@Diegorro98 Diegorro98 deleted the feature/docker_image branch August 29, 2023 06:34
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.

no proper docker file and image on docker hub does not follow instructions
8 participants