Building a custom devfile registry
Provide your developers a devfile registry so they can access devfile stacks and samples, enabling them to use devfiles to simplify and improve their containerized application development.
To create a devfile registry for your team’s container development:
-
Create a Git repository.
-
Build a devfile registry.
-
Tag and push the registry container image.
Creating a Git repository
Set up a Git repository to store the devfile stacks to package into the devfile registry.
-
Fork the devfile/registry repository.
-
Name your forked repository.
-
Add or remove any stacks you need from this repository.
-
Create a
stacks/
directory for storing the devfile stacks. Each directory understacks/
must correspond to a specific stack, for example,stacks/java-wildfly/
. -
To package any external devfile stacks or samples in your devfile registry, go to the root of your repository and create an
extraDevfileEntries.yaml
file. -
Add your devfile stacks to your
stacks/
directory. -
Make sure every devfile stack contains at least one
devfile.yaml
file. Add other required files to the stacks. These files can include VSX plug-ins, Dockerfiles, or Kubernetes manifests.
The registry build tool automatically validates your customized registry.
-
Example of extraDevfileEntries.yaml.
-
To create devfile stacks, see Authoring devfiles.
Building a custom devfile registry
Make your repository into a devfile registry by building a devfile index
container image. Deploy the devfile index
image to your cloud or cluster to form the devfile registry.
-
Golang 1.13.x or higher
-
Docker 17.05 or higher
-
Git
-
Run
./build_image.sh <path-to-devfile-registry-folder>
to build a devfile registry repository. -
In a multi-stage Docker build, add a Dockerfile to your devfile registry repository. Make sure the Dockerfile contains the following:
Example 1. DockerfileFROM quay.io/openshift-pipeline/golang:1.15-alpine AS builder # Install dependencies RUN apk add --no-cache git bash COPY . /registry # Download the registry build tools RUN git clone https://github.com/devfile/registry-support.git /registry-support # Run the registry build tools RUN /registry-support/build-tools/build.sh /registry /build FROM quay.io/devfile/devfile-index-base:next COPY --from=builder /build/index.json /index.json COPY --from=builder /build/stacks /stacks
-
Run
docker build -t devfile-index
to build the devfile registry into a container image.
The build script builds the index generator, generates the index.json
file from the specified devfile registry, and builds the stacks and index.json
into a devfile index container image. The registry build process takes the contents of your devfile registry Git repository and:
-
Packages the content of each devfile stack based on the supported media types for the devfile registry.
-
Validates the content of the devfile registry repository based on the expected registry structure.
-
Generates
index.json
from the stacks in the repository and from any extra stacks or samples mentioned in theextraDevfileEntries.yaml
file. -
Builds a devfile index container image with the devfile stack contents and
index.json
.
-
For examples on how to add Dockerfiles to your devfile registry, see the devfile/registry repository’s Dockerfile.
-
To run the registry build outside a container build, see the devfile registry build tools.
Tagging and pushing a registry container image
Use the devfile index container image to create a container in which you build, run, and deploy your application.
-
Choose a container registry.
-
Consult the documentation for your container registry and log in to the registry with the Docker CLI.
-
Push the devfile index container image to your chosen container registry:
$ docker tag -f devfile-index <registry-hostname>/<registry-username>/devfile-index:latest $ docker push <registry-hostname>/<registry-username>/devfile-index:latest
-
If your container does not build properly, consult the documentation for your container registry.
-
For information on deploying the devfile index container image, see Deploying a devfile registry.