问题
I am very new to Jhipster and Docker and I would like some help understanding the basics of how to build and deploy my application on my Heroku instance. As I am working with a friend, we will probably need some sort of integration platform such as Gitlab that will also work as our code versioning and repository.
Here is what we have done so far:
- Generated a monolithic application and tested it locally (works fine, thanks Jhipster for making it so easy).
- Pushed it on our gitlab repository.
- Created a Docker folder at the root of our application and launched
docker compose
inside.
What we think we should be doing next:
- Configuring a build using a .gitlab-ci.yml file following this example http://docs.gitlab.com/ce/ci/yaml/README.html
- Link somehow our Heroku cloud server to GitLab.
But I still have some questions:
- Should we leave the task of building the docker image to gitlab ?
- I hear about Docker hub and Docker Cloud a lot but I still don’t see the point in my case, am I wrong?
- I am not sure how to use heroku at its full potential. Any advice on this part?
So to summarize, I would like to create a Docker image from my application, build it and send it to my server. I think about using Docker, Gitlab and Heroku but I am keen to any other proposition that would help us having a fast, robust and efficient development cycle.
Thank you,
回答1:
Here are different ways to go...at least it matters that your release pipeline is triggered by CI, and not manually.
At first, yes, GitLab should be responsible for building images. These can be either stored inside the GitLab Container registry (which is avaible in the latest GitLab versions) or the heroku container registy. Both are private docker registries! No matter which one you choose, you will get a guide how to login to that registry to push to that.
I am using the GitLab registry at my work. I configure GitLab CI Runner to run using image "xetys/java-8-docker". Note, that the runner must run in order to be able to run docker inside. Start the runner using this command
docker run -d --name gitlab-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
Then you can install heroku inside gitlab CI in before_script
section in order to define a "heroku deploy" task, and a "docker push" task.
Finally, you can use "when: on_success" to make your deploy stage dependent from success of recent stages in order to trigger a deploy based on your images.
There is also a way of making your CI hooking to heroku, to make a visiual deploy pipeline, maintained by heroku. I never did that, so I can't give any meaningful advice on this.
Hope I could help in some way.
来源:https://stackoverflow.com/questions/39011705/how-to-build-test-and-deploy-using-jhipster-docker-gitlab-and-heroku