Let's look at how Wercker can help our application.
For starters, we'll use Wercker pipelines to automate the build process.
Create a directory under GOPATH for the API and copy the source code there.
Next, we'll run any unit tests that we've written.
Then we’ll perform the build and save the binary to the output directory.
Finally, we'll push a Docker image, so that we can run the API in a container.
We have a build configuration file, but before we can perform a build, we need to connect
our API repository to Wercker.
To do this, we'll log into Wercker, click the Add button, and choose Add Application.
Select the user account and then select Oracle Developer Cloud Service, which is where we created our repositories.
To access the repositories, we need to enter our credentials.
We can use the search field to find our API repository.
We'll have Wercker store an SSH key to access the repository.
After we review our settings and ensure everything’s OK, we can finish adding the application by
clicking Create.
Our Wercker application has been created.
Before we can run it, we need to add the Docker credentials to Wercker as environment variables.
On the Environment tab, we’ll create a variable for the docker username,
enter its value, and click Add. Then we'll repeat this to create a variable for the Docker password.
Since the password is a secret value that we don’t want to be readable,
we select the Protected option.
Now the application is ready to run.
This will happen automatically every time we push a commit to the Git repository.
This time, let's start it manually.
This only takes a few moments to run.
Everything was successful, and a Docker image has been pushed to the repository.
We also create a wercker.yml file for the front end.
In this case we're copying everything to the output directory.
Then we'll push a Docker image, so we can run the front end in a container.
We need to add the front end repository to Wercker.
Once again, we’ll use the Add Application Wizard."
We select Oracle Developer Cloud Service, find our front end repository, and have Wercker
store an SSH key to access the repository.
After reviewing everything, we finish adding the front end to Wercker by clicking Create.
Similar to the API, before we can run a build, we need to create our docker environment variables
for the front end application.
We create a variable for the docker username, and another variable for the docker password,
protecting the password by selecting the Protected option.
Let's start a build manually, and wait for it to finish.
The build was successful, and a Docker image has been pushed to the repository.
We pull the new Docker images so that we can run them locally.
Now we can run our entire application using Docker images.
First, let's check to make sure that nothing’s running.
We start the database, and populate it using our setup script.
Next, we run the API.
Finally, we’ll run the front end.
We’ll use the "docker ps" command to verify that everything's running -
and it is.
We open our browser, connect to our application - and voila - our containerized application
is up and running.
Learn more at cloud.oracle.com/containers/pipelines