Skip to content

Commit

Permalink
Unify Dockerfile naming and simplify + combine scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jun 23, 2022
1 parent 474e892 commit e6c00f8
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 98 deletions.
18 changes: 8 additions & 10 deletions .azure-pipelines/all-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@ parameters:

steps:
# OpenXR spec builder
- script: docker pull ruby:2.3
displayName: Pull ruby:2.3 base image

- template: build-template.yml
parameters:
command: ${{ parameters.command }}
tag: openxr-base.202110
tag: openxr-base
version: 202110

- template: build-template.yml
parameters:
command: ${{ parameters.command }}
tag: openxr.202110
tag: openxr
version: 202110

# OpenXR SDK builder
- script: docker pull ubuntu:18.04
displayName: Pull ubuntu:18.04 base image

- template: build-template.yml
parameters:
command: ${{ parameters.command }}
tag: openxr-sdk.202110
tag: openxr-sdk
version: 202110

- template: build-template.yml
parameters:
command: ${{ parameters.command }}
tag: openxr-pregenerated-sdk.202201
tag: openxr-pregenerated-sdk
version: 202201

# This image build is broken right now: E: Package 'ttf-lyx' has no installation candidate
# - template: build-template.yml
Expand Down
17 changes: 0 additions & 17 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,3 @@ jobs:
- template: all-images.yml
parameters:
command: build

# push job - runs only on master
- job: build_and_push
condition: eq(variables['build.sourceBranch'], 'refs/heads/master')
pool:
vmImage: "ubuntu-latest"
steps:

- task: Docker@2
displayName: Login to Docker Hub
inputs:
command: login
containerRegistry: docker-hub

- template: all-images.yml
parameters:
command: buildAndPush
10 changes: 7 additions & 3 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ parameters:
imageName: "khronosgroup/docker-images"
tag:
command: build
version:

steps:
- task: Docker@2
displayName: ${{ parameters.command }} ${{ parameters.tag }}
displayName: ${{ parameters.command }} ${{ parameters.tag }} ${{ parameters.version }}
inputs:
repository: ${{ parameters.imageName }}
command: ${{ parameters.command }}
tags: ${{ parameters.tag }}
Dockerfile: Dockerfile.${{ parameters.tag }}
arguments: "--build-arg \"VERSION=${{ parameters.version }}\""
tags: |
${{ parameters.tag }}.latest
${{ parameters.tag }}.${{ parameters.version }}
Dockerfile: ${{ parameters.tag }}.Dockerfile
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@ Docker container specifications which package dependencies for building
Khronos documentation and software.

Images built from this github repository are pushed to the Dockerhub
repository
repository https://hub.docker.com/r/khronosgroup/docker-images.

https://hub.docker.com/r/khronosgroup/docker-images
## Structure

Each Dockerfile is named in the form 'Dockerfile.<tag>' or
'<tag>.dockerfile', where <tag> (e.g. `openxr`, `asciidoctor-spec`) matches
the tag for that image in the Dockerhub repository.
Each Dockerfile is named `<tag>.Dockerfile` where `<tag>` (e.g. `openxr`, `asciidoctor-spec`)
matches the tag for that image in the Dockerhub repository, suffixed with both `-latest` for the
latest revision of this image, and `-<date>` representing a timestamp when this image was last
modified.

## Scripts

In general, any additional arguments are forwarded on to `docker build`,
so this is how you can pass `--no-cache` to force a rebuild, etc.
In general, any additional arguments are forwarded on to `docker build` except the first if it is
`"push"`, so this is how you can pass `--no-cache` to force a rebuild, etc.

- Single-image scripts: pass a Dockerfile name as the first argument, the tag is automatically computed.
- `./build-one.sh` - Just builds and tags the image locally, does not push to Dockerhub.
- Single-image scripts: pass a tag name as the first argument and a version as the second.
- `./build-one.sh <tag> <date>` - Just builds and tags the image locally, does not push to Dockerhub.
Use for testing modifications.
- `./build-and-push-one.sh` - Builds and tags the image locally, then pushes it to Dockerhub.
- `./build-one.sh <tag> <date> push` - Builds and tags the image locally, then pushes it to Dockerhub.
Only run this once you've committed (and ideally, pushed) the corresponding changes to this Git repo.
- `./build-and-push-all.sh` - Just calls `./build-and-push-one.sh` on the Dockerfiles listed in it.
- `./build-all.sh` - Just calls `./build-one.sh` on all the tags listed in it. Use as `./build-all.sh push`
to push all images to Dockerhub.
If you add a new Dockerfile to this repo, add it to this script too.
File renamed without changes.
16 changes: 16 additions & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Copyright 2019-2021 The Khronos Group Inc.
# SPDX-License-Identifier: Apache-2.0

set -e

(
cd $(dirname $0)
./build-one.sh asciidoctor-spec 202206 "$@"
./build-one.sh vulkan-docs-base 202206 "$@"
./build-one.sh vulkan-docs 202206 "$@"
./build-one.sh openxr-base 202110 "$@"
./build-one.sh openxr 202110 "$@"
./build-one.sh openxr-sdk 202110 "$@"
./build-one.sh openxr-pregenerated-sdk 202201 "$@"
)
17 changes: 0 additions & 17 deletions build-and-push-all.sh

This file was deleted.

24 changes: 0 additions & 24 deletions build-and-push-one.sh

This file was deleted.

9 changes: 0 additions & 9 deletions build-and-push-openxr.sh

This file was deleted.

26 changes: 20 additions & 6 deletions build-one.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
# Copyright 2019-2021, The Khronos Group Inc.
# SPDX-License-Identifier: Apache-2.0

# Pass a dockerfile name.
# Pass a Dockerfile name and version (typically the year and month).
# Optionally pass the literal text "push" as third argument to publish
# the result to dockerhub.
# Any extra arguments (including the third argument if it's not "push")
# are passed to `docker build` literally.
#
# The tag portion of the name is used as the tag within the repo.
# Name format can be either tag.dockerfile or Dockerfile.tag

set -e

Expand All @@ -13,8 +17,18 @@ REPO="khronosgroup/docker-images"
(
cd $(dirname $0)
DOCKERFILE=$1
shift
TAG=${DOCKERFILE#Dockerfile.}
TAG=${TAG%.dockerfile}
docker build "$@" . -f "$DOCKERFILE" -t "$REPO:$TAG"
VERSION=$2
shift 2
if [ "$1" == "push" ]; then
OP=$1
shift
fi
docker build "$@" . -f "$DOCKERFILE.Dockerfile" \
--build-arg "VERSION=$VERSION" \
-t "$REPO:$DOCKERFILE.latest" \
-t "$REPO:$DOCKERFILE.$VERSION"
if [ "$OP" == "push" ]; then
docker push "$REPO:$DOCKERFILE.latest"
docker push "$REPO:$DOCKERFILE.$VERSION"
fi
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion Dockerfile.openxr.202110 → openxr.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

# This is a Docker container for (interactive) OpenXR specification builds

FROM khronosgroup/docker-images:openxr-base.202110
ARG VERSION

FROM khronosgroup/docker-images:openxr-base.$VERSION
LABEL maintainer="Ryan Pavlik <[email protected]>"

# Add the entrypoint to the image
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit e6c00f8

Please sign in to comment.