- OpenShift 3.6+
- Artifactory trial license get one from here
- Install Artifactory in OpenShift following documentation provided in artifactory-docker-examples
- We will use node-version as an example project to demonstrate this integration.
- Set npm command line client to work with Artifactory Npm Registry.
create.npmrcfile and paste following content to it:registry = https://$ARTIFACTORY_URL/api/npm/$ARTIFACTORY_NPM_REPO_NAME/ _auth = $ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD email = youremail@email.com always-auth = true - Install dependencies:
npm install - Start node Server:
npm start - Access Application on: http://localhost:3000
- Build docker image:
docker build -t $DOCKER_REGISTRY/node-version . - Run docker container:
docker run -d -p 3000:3000 $DOCKER_REGISTRY/node-version - Login to Artifactory docker registry:
docker login -u ARTIFACTORY_USER -p $ARTIFACTORY_PASSWORD $DOCKER_REGISTRY - Push docker image:
docker push $DOCKER_REGISTRY/node-version
- Create OC secret to access Artifactory NPM repository given an existing
.npmrcfile:oc create secret generic secret-npmr .npmrc=.npmrc
- Create OC secret to access Docker repository:
oc create secret docker-registry rt-docker-registry --docker-server=<RT_DOCKER_REPO> --docker-username=<YOUR_USER> --docker-password=<YOUR_PASSWORD> --docker-email=<YOUR_EMAIL>
- Link docker secret to at-least 3 service accounts:
oc secrets add serviceaccount/default secrets/rt-docker-registry --for=pulloc secrets add serviceaccount/builder secrets/rt-docker-registryoc secrets add serviceaccount/deployer secrets/rt-docker-registry
Note: Replace <RT_DOCKER_REPO> with Artifactory docker registry domain in Build Config and Deployment Config before running following commands:
-
Build Config:
oc create -f nodejs-rt-bc.yaml -
Deployment Config:
oc create -f nodejs-rt-dc.yaml -
Service Creation:
oc create -f nodejs-rt-svc.yaml -
Route Creation:
oc create -f nodejs-rt-route.yaml -
Get route and access application via route in browser:
oc get route