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

Feature/updated image files #14

Closed
wants to merge 2 commits into from
Closed

Conversation

schmunk42
Copy link
Contributor

Less files, mo' fun

@mikehaertl
Copy link
Contributor

As we should try to automate the builds later with docker hub: Will this also work there? I did not check if an option like -f is supported there.

@schmunk42
Copy link
Contributor Author

It's on the "Roadmap" docker/hub-feedback#292 - since DockerHub automated build allows no testing I don't think we can use it.

Docker Cloud is able to do this: https://docs.docker.com/docker-cloud/builds/automated-build/#set-the-build-context-and-dockerfile-location

@mikehaertl
Copy link
Contributor

AFAIK Docker cloud is only an alternative UI. So if we use Docker Cloud, the images will still be published on docker hub. Can you verify this?

@schmunk42
Copy link
Contributor Author

@motin Can you help us out here?

@mikehaertl
Copy link
Contributor

DockerHub automated build allows no testing I don't think we can use it.

But we use travis for testing. I would not auto-trigger the builds on docker hub/cloud but always manually trigger builds. After an update we can wait until the travis reports success and then trigger an automated build when we see fit.

@schmunk42
Copy link
Contributor Author

After an update we can wait until the travis reports success and then trigger an automated build when we see fit.

Might also be possible with a web-hook, but why not simply push from Travis?

@mikehaertl
Copy link
Contributor

That's too much automation for my taste. We don't want to trigger a build on each and every commit.

@motin
Copy link

motin commented Mar 22, 2017

AFAIK Docker cloud is only an alternative UI. So if we use Docker Cloud, the images will still be published on docker hub. Can you verify this?

While Docker hub allows for automatic builds which are pushed to a Docker hub repository, Docker cloud can be configured for:

  • automatic builds that run either on own nodes or Docker cloud infrastructure
  • push to either Docker hub repository or an external docker repository
  • automatic tests (if they fail, the resulting image is not pushed)

I don't know how this is relevant to the testing workflow of yii2 since I am not using yii2.

@schmunk42
Copy link
Contributor Author

We don't want to trigger a build on each and every commit.

Sure we wanna trigger a build & test on every commit, but not a release & push.

@schmunk42
Copy link
Contributor Author

@motin Is there a (free) version of Docker Cloud, which can be used to build images with a custom build context, which is not possible on Docker Hub, at the moment.

@motin
Copy link

motin commented Mar 22, 2017

@motin Is there a (free) version of Docker Cloud

Yes, all accounts include 1 free managed node and building on Docker cloud's infrastructure is free as long as no private repositories are used.

, which can be used to build images with a custom build context, which is not possible on Docker Hub, at the moment.

Don't know, haven't tried using a custom build context.

@mikehaertl
Copy link
Contributor

So before merging we should verify that custom build contexts are supported on docker cloud.

@mikehaertl
Copy link
Contributor

mikehaertl commented Mar 22, 2017

Sure we wanna trigger a build & test on every commit

That's what travis does.

@schmunk42
Copy link
Contributor Author

So before merging we should verify that custom build contexts are supported on docker cloud.

Check, works!

See https://cloud.docker.com/swarm/schmunk42/repository/registry-1.docker.io/schmunk42/yiisoft-yii2-php/builds/34ff3a97-670c-46b0-8f90-0fda8e59de84 - you need an account I think.

Could you check, if you can link this repo to an account, it does not show up in my list.
Or @cebe @samdark might need to create an account on Docker Cloud.

@mikehaertl
Copy link
Contributor

There's already a yiisoft account on docker hub which probably also can be used for docker cloud. I've asked @samdark some time ago, to check if we can get access to this account. Actually we should make this an "Organization" - not sure if a similar entity exists at docker cloud.

@schmunk42 Please wait before building any images with docker hub/cloud. It's still too early to go public with something.

@schmunk42
Copy link
Contributor Author

There is https://hub.docker.com/r/yiisoft/ @samdark @cebe You have control over this?

We can use the one free private account initially - would also provide security scans. I don't wanna release it publicly yet also, but setting up the build pipelines is a major task of this project.

@mikehaertl
Copy link
Contributor

but setting up the build pipelines is a major task of this project.

I know, but please wait with this until we find an agreement of what we want to do, e.g. which flavours we want to build. It's still too early for this.

@schmunk42
Copy link
Contributor Author

It's all linked, this PR actually only makes sense after knowing that we can build on Docker Cloud and Travis with a build context.

After merging this, I'd like to update #13 accordingly.
Without having to fiddle and fake security scans (because we're building on Docker Cloud) we can finish #4. Which then leads to a better base for #7.

No public releases involved.

@mikehaertl
Copy link
Contributor

Yes, that's what I meant: A simple quick test with docker cloud is enough. Not sure what you mean by "build chain" - we don't need a complex setup there yet.

Travis is a different story. The tests already pass, as is shown in the PR, so nothing else to check here.

@schmunk42
Copy link
Contributor Author

Not sure what you mean by "build chain" - we don't need a complex setup there yet.

Ie. the combination of a GutHub repo, testing on Travis and potentially build & security scan on Docker Cloud.

Travis is a different story. The tests already pass, as is shown in the PR, so nothing else to check here.

Cool, so this is ready to merge.

@mikehaertl
Copy link
Contributor

Ie. the combination of a GutHub repo, testing on Travis and potentially build & security scan on Docker Cloud.

But shouldn't all this happen during the tests with travis? I see no connection to docker cloud as we should trigger builds manually there.

@schmunk42
Copy link
Contributor Author

But shouldn't all this happen during the tests with travis?

I'd be fine with this.

I see no connection to docker cloud as we should trigger builds manually there.

Yes, one option. Or if there's a green build. I just wanted to make sure the setup works also on the Docker infrastructure.

@@ -50,5 +50,5 @@ RUN { \
&& a2enmod rewrite

# Install composer
COPY install-composer /install-composer
COPY image-files /
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding the whole directory, shouldn't we be explicit, which files exactly we copy? Alternatively, copy the files to a directory /install-scripts or something in the container and below remove the complete directory again.

Copy link
Contributor

Choose a reason for hiding this comment

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

@schmunk42 Have you seen my comment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The structure within the image-files directory is the same as they'll land on the image.

So /usr/local/bin/docker-composer-install, according to https://github.com/docker-library/php/blob/master/7.1/Dockerfile#L129 - or opt or install-scripts

Copy link
Contributor

Choose a reason for hiding this comment

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

@schmunk42 Actually I think, we should try to remove the install script completely and instead convert it to 2-3 lines in the Dockerfile. The instructions for how to install composer on getcomposer.com are confusing now to put it mildly. They show 2 ways, both of them using weird code. We can do better I think. For example this code from their website:

EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

They use wget in the first line and php in the second line for one and the same task: download a file. Why???

I can provide a simplified set of commands, if you want.

Copy link
Contributor Author

@schmunk42 schmunk42 Mar 24, 2017

Choose a reason for hiding this comment

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

Let's keep whatever way in a script, this is much easier to maintain than in the Dockerfiles, since there are already so many of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You won't get less layers than one for all possible files we need to add - which we have with this method.

We hardly ever have to change it anymore.

I always doubt that, there are already 2 ones as you mentioned. Looks like this should be changed in composer ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

You won't get less layers than one for all possible files we need to add - which we have with this method.

We don't need the extra COPY and RUN statement, so it's 2 fewer layers.

The install script is so trivial that there can't be frequent changes. If it ever changes it makes no difference if we only have one file or if we have to go through a hadn full of Dockerfiles. The builds would break anyway so we'd notice for sure, if we forget something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need the extra COPY and RUN statement, so it's 2 fewer layers.

It's just one fewer ;), because you need to RUN something. But can we optimize the layers a bit later on. On almost all other points we're following docker-library closely and this is a similar approach. It's really not necessary to copy and paste this into all files.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just one fewer ;), because you need to RUN something.

We already have RUN statements above where we can add this. Official docker images do the same. We should not add files just for the sake of it. Otherwhise you could move almost the whole install process into an external "setup" script and only COPY and RUN that. But that's not what we do: We try to keep simple commands inside the Dockerfile. And installing composer is a simple command. As I said before: Their example is unneccessarily long and boils down to 2 commands.

Copy link
Contributor

Choose a reason for hiding this comment

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

As additional reference see the official PHP image here. They don't use an external script for a way more complex install process: https://github.com/docker-library/php/blob/master/5.6/fpm/Dockerfile#L48.

@schmunk42 schmunk42 closed this Jul 7, 2017
@schmunk42 schmunk42 deleted the feature/updated-image-files branch December 20, 2018 11:09
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.

None yet

3 participants