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

dockerized #69

Merged
merged 5 commits into from
May 17, 2019
Merged

dockerized #69

merged 5 commits into from
May 17, 2019

Conversation

smokills
Copy link
Contributor

Since not all projects can be updated to php 7.2, I've dockerized this package.

It would be interesting to create a stage in the CI pipeline and push the image on the docker hub

@nunomaduro
Copy link
Owner

Someone with experience with the stack involved in this pull request that can help validation this solution?

@nunomaduro nunomaduro added good first issue Good for newcomers help wanted Extra attention is needed labels May 16, 2019
@nunomaduro
Copy link
Owner

Related to #68

@deleugpn
Copy link
Contributor

deleugpn commented May 16, 2019

Did you get this to actually work? AFAIK, insights doesn't work on Alpine. See #43
Will test this out tomorrow

@deleugpn
Copy link
Contributor

deleugpn commented May 17, 2019

For some reason, this distribution of the Alpine image works fine. This would be pretty good for CI, indeed.

@nunomaduro Do you plan on publishing this as an official image into Docker Hub? That way, we could run Insights without installing it as a dependency of our projects. Like docker run -v /my/project:/app -it nunomaduro/phpinsights:1.0. Maybe you'd want something like docker run -v /my/project:/app -it phpinsights/laravel:1.0 so you could make the Laravel image use artisan instead. Not sure if you'd need it, though.

If you plan on doing that, it would be nice to publish the image and write the documentation accordingly. If not, the documentation would have to be more driven into how to build your own copy of the image and run it.

@nunomaduro
Copy link
Owner

nunomaduro commented May 17, 2019

I will try to find time to study this.

@smokills
Copy link
Contributor Author

@deleugpn as you can see I've used the official PHP CLI docker image, so i guess that this does the magic happens :D

@nunomaduro
Copy link
Owner

@smokills Can you update the PR with documentation? We should probably babysit the users here.

@smokills
Copy link
Contributor Author

@nunomaduro I'll do it right now :D

remove VOLUME directive and use ENTRYPOINT instead of CMD
@smokills
Copy link
Contributor Author

@nunomaduro I've updated the documentation. There is a placeholder <dockerhub namespace/imagename> in which you have to replace the name of the image that you'll push on the docker hub

@nunomaduro
Copy link
Owner

nunomaduro commented May 17, 2019

Here is the docker thing: https://hub.docker.com/r/nunomaduro/phpinsights. Can you update the PR, and resolve conflicts?

@nunomaduro
Copy link
Owner

@smokills Can you test if it's working? 🤗

@deleugpn
Copy link
Contributor

deleugpn commented May 17, 2019

@nunomaduro you need to build and push the image to Docker Hub. You'll have to:

  • docker login and provide your Docker Hub credentials
  • cd /path/to/insights
  • docker build -f docker/Dockerfile . -t nunomaduro/phpinsights:1.0.0 (or whatever version you want)
  • After the build is done, docker push -t nunomaduro/phpinsights:1.0.0

If you don't want to decide version right now, you can simply not write any version at all (e.g. docker build -f docker/Dockerfile . -t nunomaduro/phpinsights) and it will build the tag latest. You can then push the latest image and leave a warning on the docs saying it's in Beta or something and you'll start versioning the Docker image at a later time.

Edit: these steps assume you are using this exact branch.

@smokills
Copy link
Contributor Author

@nunomaduro as @deleugpn says, you need to push the image on the dockerhub. I suggest to implement this in the CI. I see that you are using travis. Here is the doc about it:

https://docs.travis-ci.com/user/docker/#pushing-a-docker-image-to-a-registry

@nunomaduro
Copy link
Owner

@deleugpn Do I need to do this every new version?

@deleugpn
Copy link
Contributor

@nunomaduro The link @smokills provided will let you automate this with Travis by having Travis push a new image for every commit on your behalf. For testing purpose, I find it easier to push the first image manually until you have time to set it up automatically.

@nunomaduro nunomaduro merged commit 2e98ebf into nunomaduro:master May 17, 2019
@nunomaduro
Copy link
Owner

@smokills smokills deleted the feature/docker branch May 17, 2019 19:35
@smokills
Copy link
Contributor Author

@nunomaduro it worked for me :)

Schermata 2019-05-17 alle 21 41 27

Another thing is that is a good practice to tag the last builded image with the latest tag, so if anyone forgot to type it in, the command will pull the latest one, that is the default pulled by docker if no tag is provided

@nunomaduro
Copy link
Owner

How exactly how I tag the last builded image with the latest tag?

@smokills
Copy link
Contributor Author

docker tag nunomaduro/phpinsights:v1.2.0 nunomaduro/phpinsights:latest and after that you have to push it to the registry, like the previous one

@nunomaduro
Copy link
Owner

Can we make this docker run -it --rm -v /path/to/app:/app nunomaduro/phpinsights better? Like without specifying the path? And just running on the current path?

@smokills
Copy link
Contributor Author

I think that this is not possible, because this it's how docker works. With that command you are basically saying: pull nunomaduro/phpinsights image from the docker registry, mount the /path/to/app of your host into the /app path into the container (it's kind of a copy), with the flag -it you are saying that you want an "interactive shell" and with --rm you are saying that after the command terminate, docker will remove the container from your machine

@nunomaduro
Copy link
Owner

Thanks you both for helping on this. @smokills @deleugpn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants