Making Docker images
Last updated
Last updated
This chapter discusses the process of baking (i.e. creating) images for docker hub. It also gives a recipe for creating docker images. If you are interested only in installing RAP4, you do not need this chapter.
Docker images are baked when the Ampersand source code for RAP4 is ready to be deployed. This results in three files, to be stored on Docker hub:
RAP4 is deployed as shown in this picture
Knowing what needs to be done allows you to understand how we make Ampersand's docker images. If you just want to do it, follow the steps below. We assume that you are working on an Ubuntu machine with bash
as its command line interface.
First I checked that docker and docker-compose are installed on my computer:
RAP is built on Ampersand and is compiled with Ampersand. For this reason, the RAP image builds on an Ampersand image. Run ./build.sh to build the initial ampersand container that serves as a base for the RAP4 application (or any other Ampersand application). This base images holds all required packages and the (at that moment) latest version of the ampersand compiler the workflow around this container can/should be improved since now the easiest way to rebuild is to remove the container (docker rmi ampersand:latest)
I cloned the docker files into a local directory by the following command:
and sat back to watch an image being created. This takes over an hour. I left the session up and running, because stopping the session means that the docker build process stops. After coming back a day later, I verified that the image is present by running the same command again. That produced the following output:
When you build an image where nothing changes (as shown above), this takes virtually no time at all. However, if you run a fresh image from scratch, it takes a while. Should you want to close your SSH-session in which docker is running, that docker process will be killed. If you want to leave docker running in the background, https://www.tecmint.com/keep-remote-ssh-sessions-running-after-disconnection/
will help. Best thing is to anticipate on it. However, if you didn't anticipate this, you can still send docker to the background by ^Z
and give the disown -h
command. (The latter is however the least elegant way.)
I checked whether all images are built by the docker images
command:
For this step, you need an account on docker-hub. Then Docker will simply push the generated images to docker hub by means of the push-command:
At this point the images are published and this chapter is done. However, it is good to discuss a few collateral issues: deployment, maintenance and security.
We are making three containers: one for the database, one for the RAP4 application, and one for PhpMyAdmin. Containers are built from images by the command docker-compose
:
This command brings all three containers up and runs them in the background. For this to happen, the file docker-compose.yml
must be in the current directory.
I checked whether the containers are running by means of the docker ps
command.
Completion of this step allowed access to RAP4 from an arbitrary computer on the internet:
The database is accessible on port 8080:
The docker-compose up
command aggregates the output of each container. When the command exits, all containers are stopped. Running docker-compose up -d
starts the containers in the background and leaves them running.
To interfere with RAP4 as it is running, you need to get into the Rap4 container. It is not enough just being on the server, because all the data is in the container (rather than directly on the server). To go into the Rap4 container, use the command
To inspect and change the local settings, you need the file localsettings.php
on directory ~/git/Ampersand-models/RAP4/include
. This step requires section 5 to be finished successfully. This file contains comments that guide you to use the correct settings in a development situation and in a production situation. Read the file and follow the instructions it contains, especially when making the transition from development to production.
In the source code of RAP4, in the file SIAM_importer.adl:
disable "RAP4_LoginForDevelopment.ifc", to prevent users from seeing
enable "RAP4_LoginForProduction.ifc"
disable "../SIAM/SIAM_AutoLoginAccount.adl"
Is there anything we must alter in localsettings.php before going live?
This is decribed in the file docker-compose.yml
If you need to install docker, follow the instructions on .