parameters:
  imageName: 'freeipa-azure-builder:latest'

steps:
- script: |
    set -e
    echo '{ "ipv6": true, "fixed-cidr-v6": "2001:db8::/64" }' > docker-daemon.json
    sudo mkdir -p /etc/docker
    sudo cp docker-daemon.json /etc/docker/daemon.json
    sudo chown root:root /etc/docker/daemon.json
    sudo systemctl restart docker
    sudo modprobe ip6_tables
  displayName: Configure containerization to allow IPv6 network

- script: |
    set -e
    sudo modprobe {nfs,nfsd}
  displayName: Configure NFS to allow NFS server/client within containers

- task: DownloadPipelineArtifact@0
  displayName: Download prebuilt packages
  inputs:
    artifactName: 'packages-$(Build.BuildId)-$(Agent.OS)-$(Agent.OSArchitecture)'
    targetPath: $(Build.Repository.LocalPath)/dist

- task: DownloadPipelineArtifact@0
  displayName: Download pre-built container
  inputs:
    artifactName: 'image-$(Build.BuildId)-$(Agent.OS)-$(Agent.OSArchitecture)'
    targetPath: $(Build.Repository.LocalPath)

- script: |
    set -e
    docker load --input $(Build.Repository.LocalPath)/freeipa-azure-builder-container.tar.gz
    docker images
    docker inspect freeipa-azure-builder:latest
  displayName: Import pre-built container to the engine
