<file_sep>#!/usr/bin/env bash

if [ ! -z "${VAULT_PASSWORD}" ]; then
  echo "Using vault password from VAULT_PASSWORD environment variable" >&2
fi

echo "${VAULT_PASSWORD}"
<file_sep># Python images

This directory contains a Dockerfile for the uisautomation python image. This
image is simply the upstream Python Alpine image with updates applies, various
useful packages installed and a small set of pre-installed Python modules. These
modules are those which take a long time to install or which are common to all
of our products.

## Tags

* ``python`` is a base Python image. Tags: ``3.6-alpine``, ``alpine``, ``latest``
* ``django`` is an image with Django and common applications installed. Tags:
  ``2.0``, ``2.0-py3.6``, ``2.0-py3.6-alpine``, ``2.0-alpine``, ``alpine``,
  ``latest``

## Usage

Use like the upstream alpine image:

```Dockerfile
FROM uisautomation/python:3.6-alpine

# ...
```
<file_sep># Automation docker images

> **This repository is now hosted on the Cambridge
> [Developers Hub](https://gitlab.developers.cam.ac.uk/uis/devops/infra/dockerimages/).

[![CircleCI](https://circleci.com/gh/uisautomation/dockerimages.svg?style=svg)](https://circleci.com/gh/uisautomation/dockerimages)

This repository contains configuration to build the [UIS automation docker
images](https://hub.docker.com/r/uisautomation/). The images are built nightly
via CircleCI and pushed to Docker hub.

## Images

The following image types are built. See the README files in each image's
directory for more details.

* [python](python/README.md)
* [django](python/README.md)
* [ucam-webauth-proxy](ucam-webauth-proxy/README.md)

## Configuration

The [CircleCI configuration](.circleci/config.yml) iterates over the image types
and builds the docker images in each directly. Different image types may have
different versions built. If the job is running on ``master``, the images are
also pushed to Docker hub.

The CircleCI project must be set up with the Docker hub username and password in
the ``DOCKER_USER`` and ``DOCKER_PASS`` environment variables. For the
uisautomation Docker hub account see the [shared documentation
repo](https://github.com/uisautomation/docs) for these credentials.
<file_sep># The openstack SDK is an enabler for all the OpenStack modules at
# https://docs.ansible.com/ansible/latest/modules/list_of_cloud_modules.html#openstack
openstacksdk

# The netaddr module is neded to use the ipaddr jinja filter as used in the docker swarm
# playbook when creating custom networks
netaddr
<file_sep>FROM python:$PYTHON_VERSION-alpine

# Add our base requirements and install
ADD ./requirements/ /tmp/requirements/

# Update and upgrade system packages and install common Python modules.
#
# For the moment we pin pip at being less than 19.0 because of
# https://github.com/pypa/pip/issues/6158.
RUN apk --no-cache upgrade && \
	apk --no-cache add git vim libffi libxml2 libxslt postgresql-client && \
	apk --no-cache add \
		postgresql-dev libffi-dev gcc g++ musl-dev libxml2-dev libxslt-dev libstdc++ && \
	pip install --no-cache-dir --upgrade 'pip<19.0' && \
	pip install --no-cache-dir --upgrade --no-cache -r /tmp/requirements/$REQUIREMENTS.txt && \
	apk del postgresql-dev libffi-dev gcc g++ musl-dev libxml2-dev libxslt-dev libstdc++

<file_sep>FROM python:3.7

ADD requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt

RUN pip install 'ansible~=$ANSIBLE_VERSION'

ENV VAULT_PASSWORD=
ADD ansible.cfg /etc/ansible/ansible.cfg
ADD vault-password /usr/local/bin
WORKDIR /workspace

ENTRYPOINT ["ansible-playbook"]
<file_sep># Ansible playbook

Packaged Ansible playbook with vault support.

Run via:

```bash
$ export VAULT_PASSWORD="<PASSWORD>"
$ docker run \
    -t \
    -e VAULT_PASSWORD \
    -v ${SSH_AUTH_SOCK}:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent \
    -v $PWD:/workspace:ro \
    uisautomation/ansible-playbook:2.6 \
    <ansible-playbook options>...
```
