Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Continuous Deployment via Github action to build public Graphene Dock…
Browse files Browse the repository at this point in the history
…er image.

The action logs into Docker Hub via Github Secrets, builds the Graphene base Docker image (currently only for AKS), and pushes the resulting image to Docker Hub.
  • Loading branch information
vahldiek committed Nov 12, 2020
1 parent 8eee4a4 commit 4ba93b6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 44 deletions.
13 changes: 13 additions & 0 deletions .ci/gsc.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ pipeline {
'''
}
}
stage('Test_CD') {
steps {
sh '''
# Test the build of Graphene base images which are automatically
# pushed to Docker Hub after a merge. This does not test the actual
# continuous deployment Github action, instead only tests the
# underlying script.
cd Tools/gsc
make build-images
make distclean
'''
}
}
stage('Test') {
steps {
sh '''
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/graphene-base-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Graphene Docker Image CD

on:
push:
branches: [ master ]

jobs:

build:
if: ${{ github.repository == 'oscarlab/graphene' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Python dependencies
run: |
pip install jinja2 pyyaml docker
- name: Build the Graphene Docker image
env: # Set Docker Hub account information to environment variables
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
cd Tools/gsc
make build-images
make push-images
37 changes: 32 additions & 5 deletions Tools/gsc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
# template/Dockerfile.*.compile.template changes), these automatically generated files need to be
# updated. Generally, changes to Graphene do not require rebuilding these Docker files.

IMAGES=graphene_aks
IMAGES=aks
VERSIONS=latest
# Official Docker Hub organization name. In case of a name change in Docker Hub, this name must be
# changed.
DOCKERHUB_ORGANIZATION=graphenelibos

all: $(addsuffix .dockerfile, $(addprefix $(addprefix images/, ${IMAGES}), .${VERSIONS}))
all: generate-dockerfiles build-images

config.aks.%.yaml:
printf \
Expand All @@ -20,15 +23,39 @@ config.aks.%.yaml:
Repository: \"https://github.com/intel/SGXDataCenterAttestationPrimitives.git\"\n\
Branch: \"DCAP_1.7 && cp -r driver/linux/* .\"\n" > $@

images/graphene_aks.latest.dockerfile: config.aks.master.yaml
images:
mkdir -p images

images/graphene_aks.latest.dockerfile: config.aks.master.yaml images
./gsc build-graphene -f -c $< graphene-aks
mv graphene-aks/Dockerfile.compile $@
$(RM) -r graphene-aks

.PHONY: generate-dockerfiles
generate-dockerfiles: $(addsuffix .dockerfile, $(addprefix $(addprefix images/, graphene_${IMAGES}), .${VERSIONS}))

.PHONY: build-images
build-images: $(addprefix $(addprefix build-, $(IMAGES))-, $(VERSIONS))

.PHONY: build-aks-%
build-aks-%: images/graphene_aks.%.dockerfile
docker build --rm --no-cache -t $(DOCKERHUB_ORGANIZATION)/aks:$* -f images/graphene_aks.$*.dockerfile images/

.PHONY: push-images
push-images: $(addprefix $(addprefix push-, $(IMAGES))-, $(VERSIONS))

.PHONY: push-aks-%
push-aks-%:
docker push $(DOCKERHUB_ORGANIZATION)/aks:$*

.PHONY: distclean
distclean: clean
$(RM) images/*
distclean: clean clean-images
$(RM) -r images/

.PHONY: clean
clean:
$(RM) config.aks.*.yaml

.PHONY: clean-images
clean-images:
docker rmi -f $(addprefix $(addprefix $(DOCKERHUB_ORGANIZATION)/, $(IMAGES)):, $(VERSIONS))
39 changes: 0 additions & 39 deletions Tools/gsc/images/graphene_aks.latest.dockerfile

This file was deleted.

0 comments on commit 4ba93b6

Please sign in to comment.