Continuous Integration and Delivery with Docker

The continuous integration setup consists of:

  • running unit tests
  • building the image that we use to build our service
  • running the build container and compiling our service
  • building the Docker image that we run and deploy
  • pushing the final image to a Docker registry

Continuous delivery is all about reducing risk and delivering value faster by producing reliable software in short iterations.

Let’s take a Hello World web server written in Go as an example service. You can find all the code used in this example here: ://github.com/ContainerSolutions/cd-with-docker-tutorial

HTTPS

Java HTTPS Client Example

Question: Can you share some source code for a Java HTTPS client application?

Sure, here’s the source code for an example Java HTTPS client program I just used to download the contents of an HTTPS (SSL) URL.

I used this program to troubleshoot a problem with Java and HTTPS URLs, including all that nice Java SSL keystore and cacerts stuff you may run into when working with Java, HTTPS/SSL, and hitting a URL.

This Java program should work if you are hitting an HTTPS URL that has a valid SSL certificate from someone like Verisign or Thawte, but will not work with other SSL certificates unless you go down the Java keystore road.

package foo;
import java.net.URL;
import java.io.*;
import javax.net.ssl.HttpsURLConnection;

public class JavaHttpsExample
{
public static void main(String[] args)
throws Exception
{
String httpsURL = "https://your.https.url.here/";
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
InputStream ins = con.getInputStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader in = new BufferedReader(isr);

String inputLine;

while ((inputLine = in.readLine()) != null)
{
System.out.println(inputLine);
}

in.close();
}
}
Just change the URL shown there to the HTTPS URL you want to access, and hopefully everything will work well for you.