Dockerfile description and OpenShift configuration file of the NGINX in order to create a docker image and deploy a corresponding NGINX instance to connect to FIWARE Wirecloud in an OpenShift environment.
In order to create the proper image you need to have installed docker engine. The first command is used to generate the docker image from the defined Dockerfile.
docker build -f Dockerfile -t flopez/nginx:latest .
It creates the corresponding docker image tagged with flopez/nginx. The next step is upload the image into a repository (in our case Docker Hub). We need to login into our user:
docker login
And them push the new created image into our repository
docker push flopez/nginx:latest
To start to work with OpenShift, you need to be registered in the corresponding environment.
oc login <OpenShift server>
This command will request you the username and password to access to the proper OpenShift environment. Now, to deploy a new application based on the current configuration files, the first step is the creation of the proper application in the OpenShift environment. Just execute the command:
oc new-app -e WIRECLOUD_SERVER=<hostname of wirecloud service> flopez/nginx:latest --name nginx -o yaml > nginx.yaml
Keep in mind that it is needed to specify the wirecloud server hostname inside the OpenShift environment in order to know to which Server we should redirect the corresponding requests. The docker image flopez/nginx is deployed publicly in Hub Docker public repository. This operation will create the definition of the new application nginx with the corresponding yaml description file. We do not use this created description file but the one that we provided, due to we need to edit the content. You can compare the content inside config folder folder with the generated one to see the differences. Finally, keep in mind that in OpenShift the hostname has the format:
<service name>.<project name>.svc
Furthermore, to deploy our nginx application just execute the corresponding command:
oc create -f config/
Last but not least, if we want to delete completely all the resources generated
with these configuration files, just execute the corresponding command, specifying
the name of the application that was created in the execution of the oc new-app
command:
oc delete all -l app=nginx
These scripts are licensed under Apache License 2.0.