In this lab, we will use demonstrate how containerization make it easy to deploy your application to the cloud. We take a web application called Drupal https://www.drupal.org/ and customize it. Once we get it working the way we want we will package up the container into a new image, publish it to Docker Hub, then deploy the image to the cloud where we will run our application. It should give your pretty good insights as to how the DevOps process and Cloud Computing work.
ist346-labs
PS > cd ist346-labs
PS ist346-labs> $Env:COMPOSE_CONVERT_WINDOWS_PATHS=1
PS ist346-labs> git pull origin master
lab-I
folder:PS ist346-labs> cd lab-I
Heroku is a cloud provider that utilizes Amazon Web Services to deploy resources. We are using Heroku because they have a very easy to use user interface and offer a very generous free package to developers who are just getting started.
You can sign up for a free account at https://www.heroku.com/
Once you get access to your free account, and reach the dashboard. Continue on to the next step.
For this lab we are going to create a cloud database service to work with, this will cut down the need to migrate data between your computer and Heroku, which is beyond the scope of this class. The database we will create is a popular open-source relational database called PostgreSQL https://www.postgresql.org/.
ist346-netid
for example my app would be ist346-mafudge
and click create app.Heroku Postgres
and follow the prompt for the free dev version. Click provision
to create the database.settings
tab, then the view credentials
button and you should see the setting for your database, it will look like the screen below.
NOTE: Did you screw up?? No big deal you can reset you database in the same location in the settings. This will clear you database and allow you to start over
To get started start the up the Drupal application. Navigate to the lab-I folder in your terminal. Then bring up the drupal container:
PS ist346-labs\lab-I> docker-compose up -d
When its finished building the container from the Dockerfile
you should see:
Creating lab-i_drupal_1 ... done
Once the container begins to run navigate to the locally running Drupal install http://localhost:8080
You will see the setup screen:
Choose Language
Select English
Choose Profile
Select Demo: Umami Food Magazine (Experimental)
This will install a sample website for us to use.Setup Database
fill in the options
a. Select PostgreSQL
as the database.
b. Database name
should be the Database
from your Heroku page.
c. Database username
should be the User
from your Heroku page.
d. Database password
should be the Password
your the Heroku page.
e. Under Advanced Options, the Host
should be the Host
your the Heroku page.Save and Continue
it will take a few minutes as the Drupal system uses the cloud to create your database on the cloud-hosted PostgreSQL service.WARNING: BEACUSE WE ARE USING A ==FREE== CLOUD DATABASE SERVICE YOUR WEBSITE WILL BE SLOW!
15 minutes later (or so….)
Site Email Address
enter your own email address.
b. For site maintenance account
enter admin
c. For the password
enter IST346
d. For default country
select United States
e. For default time zone
choose UTC
f. click save and continue
After another minute you should see the Umami website we created with Drupal.
Auth0 is a cloud-based authentication as a service offering. It allows our application to authenticate from a variety of sources, and we will use it to allow users to login to our site with their Google accounts. It is also free to get started and try out. Auth0 uses the OAuth2 authentication protocol to authenticate users. This protocol is used by a variety of vendors such as Facebook, Twitter, Microsoft and Google. You can learn more about OAuth2 on the web. We will use Auth0 to configure Drupal to authenticate users.
Tenant Domain
for Auth0 for the API endpoints. Enter ist346netid
for this value. For example my Tenant Domain is ist346mafudge
then click Next
.Account Type
should be Personal
and your Role
should be Non-Developer
. For project select Just playing around
and click Create Account
drupal
, select Regular Web Applications
and click Create
Applications
on your dashboard.drupal
application, and click the settings
tab to view the settings, you will need these later:
http://localhost:8080/auth0/callback
b. Allowed Web Origins http://localhost:8080
c. Allowed Logout URLs http://localhost:8080/user/logout
Now that Auth0 is setup we can install the Auth0 drupal module, the module is already installed on the website, but it still needs to be configured
http://localhost:8080
click the Extend
button at the top.Auth0
plugin, which is under the heading OTHER
, and check the box next to it, and click install
.Configuration
button at the top. If everything is correct you should see the Auth0 settings under system (show below)
Auth0
then enter the settings retrieved from Auth0 like below:
a. For Client ID
enter the Client ID
value from the Auth0 website.
b. For the Client Secret
enter the Client Secret
value from the Auth0 website.
c. For the Domain
enter the Domain
from the Auth0 website.Save
Login with Google
button.g.syr.edu
Google account.Authorize App
consent screen which you must accept to complete the process.Whew!! that was a lot of work, but what happens when I restart my container? EVERYTHING WILL BE GONE! A lot of effort when in to building this site EXACTLY the way we want it. Wouldn’t it be nice to save the changes we’ve made in this container so we can run it in the cloud? That’s what we will do next!
Create a new image of our Drupal website. Be sure to use the app name you created when you setup Heroku. It should be ist346-netid
for example my command is: docker commit lab-i_drupal_1 registry.heroku.com/ist346-mafudge/web
Yours should be:
PS ist346-labs\lab-I> docker commit lab-i_drupal_1 registry.heroku.com/ist346-NETID/web
where you replace NETID
with your netid.
The docker commit
command creates an image from your running container. You can check to make sure the image is there by typing:
PS ist346-labs\lab-I> docker images
and be on the lookout for registry.heroku.com/ist346-mafudge/web
PS ist346-labs\lab-I> heroku login
PS ist346-labs\lab-I> heroku container:login
PS ist346-labs\lab-I> docker push registry.heroku.com/ist346-NETID/web
again replace NETID
with your netid.With the image pushed to Heroku, we can deploy the app!
First you need to configure our app allow an HTTP server to run in Heroku (Your only need to run this once)
PS ist346-labs\lab-I> heroku labs:enable -a ist346-NETID runtime-new-layer-extract
where NETID
is your netid.
PS ist346-labs\lab-I> heroku container:release -a ist346-NETID web
again where NETID
is your netid.
open app
button in the upper right corner of the screen!Go back and configure Auth0 so that it supports your Heroku website. The URLs should be similar to the test website except the hostname and port will be different.