Skip to content

Commit 42533aa

Browse files
authored
Add NNF Container Tutorial (#1)
This adds a sample application complete with Dockerfile and instructions on how to deploy it via a container workflow on an NNF system. Signed-off-by: Blake Devcich <blake.devcich@hpe.com>
1 parent ae97752 commit 42533aa

9 files changed

Lines changed: 581 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Docker build and push
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- 'master'
12+
- 'releases/v*'
13+
- 'feature/*'
14+
15+
env:
16+
# TEST_TARGET: Name of the testing target in the Dockerfile
17+
TEST_TARGET: testing
18+
19+
# DO_TEST - true to build and run unit tests, false to skip the tests
20+
DO_TEST: false
21+
22+
# DO_PUSH - true to push to the HPE_DEPLOY_REPO, false to not push
23+
DO_PUSH: true
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- uses: actions/checkout@v2
31+
32+
- name: Lowercase repository name for docker build
33+
id: lowercase-repository-name
34+
run: |
35+
echo "HPE_BUILD_REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
36+
echo "HPE_DEPLOY_REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
37+
38+
- name: set TAG & TESTTAG for main/master
39+
if: ${{ github.event.repository.default_branch == 'main' || github.event.repository.default_branch == 'master' }}
40+
run: |
41+
echo "TAG=${{ github.sha }}" >> ${GITHUB_ENV}
42+
echo "LATESTTAG=latest" >> ${GITHUB_ENV}
43+
echo "TESTTAG=test-${{ github.sha }}" >> ${GITHUB_ENV}
44+
45+
- name: set TAG & TESTTAG for all other branches
46+
if: ${{ github.event.repository.default_branch != 'main' && github.event.repository.default_branch != 'master' }}
47+
run: |
48+
echo "TAG=dev-${{ github.sha }}" >> ${GITHUB_ENV}
49+
echo "LATESTTAG=dev-latest" >> ${GITHUB_ENV}
50+
echo "TESTTAG=test-${{ github.sha }}" >> ${GITHUB_ENV}
51+
52+
- name: Docker login
53+
uses: docker/login-action@v1
54+
with:
55+
registry: ghcr.io
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Build the test Docker image
60+
if: ${{ env.DO_TEST == 'true' }}
61+
id: docker_build_test_target
62+
uses: docker/build-push-action@v2
63+
with:
64+
push: false
65+
target: ${{ env.TEST_TARGET }}
66+
tags: ${{ env.HPE_BUILD_REPO }}:${{ env.TESTTAG }}
67+
68+
- name: Run the Docker image unit tests
69+
if: ${{ env.DO_TEST == 'true' }}
70+
run: docker run ${HPE_BUILD_REPO}:${TESTTAG}
71+
72+
- name: Build the final Docker image
73+
id: docker_build
74+
uses: docker/build-push-action@v2
75+
with:
76+
push: false
77+
tags: ${{ env.HPE_BUILD_REPO }}:${{ env.TAG }}
78+
79+
- name: Peek at the docker images
80+
run: docker images
81+
82+
- name: Tag the build
83+
run: docker tag docker.io/${HPE_BUILD_REPO}:${TAG} ghcr.io/${HPE_DEPLOY_REPO}:${TAG}
84+
85+
- name: Tag the build as latest
86+
run: docker tag ${HPE_BUILD_REPO}:${TAG} ghcr.io/${HPE_DEPLOY_REPO}:${LATESTTAG}
87+
88+
- name: Push the tagged build
89+
if: ${{ env.DO_PUSH == 'true' }}
90+
run: docker push ghcr.io/${HPE_DEPLOY_REPO}:${TAG}
91+
92+
- name: Push the build tagged as latest
93+
if: ${{ env.DO_PUSH == 'true' }}
94+
run: docker push ghcr.io/${HPE_DEPLOY_REPO}:${LATESTTAG}

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Start from the NearNodeFlash MPI File Utils Image that is used for Data Movement. This is an easy
2+
# way to get MPI File Utils/mpi-operator as a base. Use a stage for building the application.
3+
# Alernatively, use mpi-operator's image directly:
4+
# FROM mpioperator/openmpi:0.3.0 AS build
5+
FROM ghcr.io/nearnodeflash/nnf-mfu:master AS build
6+
7+
# Install build tools
8+
RUN apt update
9+
RUN apt install -y make libopenmpi-dev
10+
11+
# Build application
12+
WORKDIR /src
13+
COPY src .
14+
RUN make
15+
16+
# Final stage - start fresh and don't carry over the build artifacts
17+
FROM ghcr.io/nearnodeflash/nnf-mfu:master
18+
19+
# Copy application from build stage into final stage
20+
COPY --from=build /src/mpi_hello_world /usr/bin/mpi_hello_world

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
all:
3+
docker build . -t nnf-container-example:0.0.1

0 commit comments

Comments
 (0)