This repository contains the docker image sources used in FUN's new OpenShift-based infrastructure to run Open-edX, DjangoCMS and other applications.
Building a service Docker image can be achieved thanks to the bin/build
utility script, e.g.:
$ bin/build nginx
For a target service
, the build
script expects a Dockerfile
and context to
be located in a docker/images/<service>/
directory, e.g.:
.
├── ...
├── docker
│ └── images
│ └── nginx
│ └── Dockerfile
└── ...
The target build image will be automatically tagged with the following pattern:
fundocker/openshift-<service>:<version>
with <service>
the service name (e.g. nginx
) and <version>
the version
tag of the original service image (e.g. 1.13
) extracted from the first
FROM
statement of the service's Dockerfile
, e.g.:
# docker/images/nginx/Dockerfile
FROM nginx:1.13
# ...
Once the build succeeds, you can check image availability via:
$ docker images "fundocker/openshift*"
REPOSITORY TAG IMAGE ID CREATED SIZE
fundocker/openshift-nginx 1.12 97fa5695dab6 22 hours ago 108MB
fundocker/openshift-nginx 1.13 367a1bb94e8a 23 hours ago 109MB
Once built, you can publish your image to DockerHub
via the bin/publish
script, e.g.:
$ bin/publish nginx
The script will automatically look up for a built image tagged with the pattern described in the previous section and will push this new image to the DockerHub public repository.
You will need to create a DockerHub account first and log in via the
docker login
command.
To make sure our release process is reproducible, we have automated image build and publication using CircleCI.
Our building strategy follows:
- All services are constantly built when a new pull request is proposed and the
related branch is merged to
master
. - We publish a new image to DockerHub when the git repository is tagged with a
tag matching the following pattern:
<service>-<version>
, e.g.nginx-1.13
. - We publish all images to DocherHub when the git repository is tagged with a
tag matching the following pattern:
all-<date>
, e.g.all-20180423
.
To add a new service foo
, create the service directory first:
$ mkdir docker/images/foo
Then write OpenShift compatibility statements that will add new Docker layers over the base image (see OpenShift's documentation to get official guidelines):
# docker/images/foo/Dockerfile
FROM foo:2.4.12
# Allow foo to be started by a non privileged user
RUN chgrp -R 0 /var/run/foo
- Always derive your
Dockerfile
from an official image and make sure it is still maintained. - When building an image, the building context is the
docker/images/<service>
directory, so if you need to add files to the context (e.g. for aCOPY
statement), make sure to place them in this directory.
Once your image is ready to be published, you are invited to:
- Update the list of available images in the next section of this document.
- Push your feature-branch (you've created a feature branch, right?) to GitHub and open a new pull request (PR).
- Look for CI status and wait for a review of your work. If everything went well, proceed to the next step.
- Create a new repository on DockerHub under the
fundocker
organization umbrella (it should be named following our image tagging pattern - see above), and give thebot
teamwrite
access to this repository. - Tag the repository (see building strategy in the CI/CD section) to publish your image:
$ git tag nginx-1.13
$ git push origin --tags
- Merge your PR.
We maintain a restricted set of OpenShift-compatible images we use in production. An exhaustive list of those Docker images follows:
- Source: Dockerfile
- Availability: fundocker/openshift-nginx
This work is released under the MIT License (see LICENSE).