I will be very thankful if anybody can help me out with this dockerfile and kubernetes conf file to perform the following tasks.
I wanted to create a Dockerfile which can fetch the source code of an angular app from github and build it and also push it to the docker hub.
I have tried with the Dockerfile below but there are issues with the file. If anyone can guide me to the mistakes I have done or can provide a suitable Docker file then it will be great.
Also If possible I also want to ask for the kubernetes conf file which can pull the image from the dockerhub and run it as a service.
Thank You.
2
Answers
There already is a working Dockerfile in the repo that you can use. You can just clone the repo and build it.
If you can’t do that and want to clone the repo from inside the Dockerfile, you can modify it like this
Build and run with
Then go to http://localhost:5000/ in a browser.
As for getting it to run on AWS/Kubernetes, I suggest making a new question for that. You should only have one question in a Stackoverflow post.
Assuming that you have Docker and Kubernetes solutions setup and ready.
First, as mentioned by the others, the best option is just to use Dockerfile from the repo instead of writing your own:
Please clone the repo:
Create your Docker repository – steps are presented here – in this example I will create a public repository named
testing-aston-villa-app
.Login to the Docker registry on your host:
Build and push Docker image to your repo – commands are like this:
In our example (make sure that you are in the directory where repo is cloned):
Ok, image is now on your Docker repository. Time to use it in Kubernetes. Please do below instructions on the host where you have
kubectl
installed and configured to interact with your cluster.Following yaml file has definitions for deployment and for service. In
image
field please use<your_username>/my-private-repo
name:Please save this yaml and run
kubectl apply -f {file.yaml}
.After applied, check if pods are up and service exits:
Now, let’s check if service is working by making request to it from another pod:
Note that I used IP address
10.101.176.184
because it’s the IP address of theservice/aston-villa-app-service
. In your case, it will be probably different.