Skip to content

Commit

Permalink
adding start of base image for flux-core
Browse files Browse the repository at this point in the history
note that there is a bug in spack that must be fixed for the
multistage build (the next container coming) to work.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Aug 5, 2022
1 parent cece758 commit a81100b
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/build-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and Deploy Container

on:

# Always have a base image ready to go - this is a nightly build
schedule:
- cron: 0 3 * * *

# Allow manual trigger of a build
workflow_dispatch:

# On push to main we build and deploy images
push:
branches:
- master

# Publish packages on release
release:
types: [published]

jobs:
build:
if: github.repository == 'flux-framework/flux-core' # Don't run in forks
permissions:
packages: write
strategy:
fail-fast: false
matrix:

# Dockerfiles to build, a matrix supports future expanded builds
container: [["config/docker/Dockerfile.base", "ghcr.io/flux-framework/flux-core-base"]]
# This will be enabled after the first container builds.
#["config/docker/Dockerfile", "ghcr.io/flux-framework/flux-core-ubuntu"]]

runs-on: ubuntu-latest
name: Build
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Make Space For Build
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
# It's easier to reference named variables than indexes of the matrix
- name: Set Environment
env:
dockerfile: ${{ matrix.container[0] }}
uri: ${{ matrix.container[1] }}
run: |
echo "dockerfile=$dockerfile" >> $GITHUB_ENV
echo "uri=$uri" >> $GITHUB_ENV
- name: Pull previous layers for cache
run: docker pull ${uri}:latest || echo "No container to pull"

- name: Build Container
run: |
container=$uri:latest
docker build -f ${dockerfile} -t ${container} .
echo "container=$container" >> $GITHUB_ENV
- name: GHCR Login
if: (github.event_name != 'pull_request')
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy
if: (github.event_name != 'pull_request')
run: |
docker push ${container}
- name: Tag and Push Release
if: (github.event_name == 'release')
run: |
tag=${GITHUB_REF#refs/tags/}
echo "Tagging and releasing ${uri}:${tag}"
docker tag ${uri}:latest ${uri}:${tag}
docker push ${uri}:${tag}
43 changes: 43 additions & 0 deletions etc/docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ghcr.io/rse-ops/cuda:ubuntu-22.04-cuda-11.3.1

# From flux-core root
# docker build -f etc/docker/Dockerfile.base -t ghcr.io/flux-framework/flux-core-base .

RUN apt-get update && \
apt-get install -y unzip gfortran python3-dev && \
spack compiler find && \
apt-get install -y libcurl4-openssl-dev libssl-dev && \
# py-jsonschema will fail without it
pip3 install tomli

# /code is the working directory for code
WORKDIR /code
COPY . /code

# This is for a spack environment/view to install from there
RUN mkdir -p /opt/flux-env \
&& (echo "spack:" \
&& echo " view:" \
&& echo " mfem:" \
&& echo " root: /opt/flux-view" \
&& echo " link_type: copy" \
&& echo " packages:" \
&& echo " all:" \
&& echo " target:" \
&& echo " - x86_64_v3" \
&& echo " config:" \
&& echo " concretizer: clingo" \
&& echo " compiler:" \
&& echo " target:" \
&& echo " - x86_64_v3" \
&& echo " install_missing_compilers: true" \
&& echo " concretization: together") > /opt/flux-env/spack.yaml

RUN cd /opt/flux-env && \
. /opt/spack/share/spack/setup-env.sh && \
spack env activate . && \
spack develop --path /code flux-core@master && \
spack add flux-core@master && \
spack external find && \
spack mirror add develop https://binaries.spack.io/develop && \
spack install --use-cache --only dependencies
20 changes: 20 additions & 0 deletions etc/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Flux Core Docker

We provide a [Dockerfile.base](Dockerfile.base) to build an ubuntu base image,
and (will provide) a `Dockerfile` to build a smaller one with a multi-stage build. 🚧️

Updated containers are built and deployed on merges to the master branch and releases.
If you want to request a build on demand, you can [manually run the workflow](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow) thanks to the workflow dispatch event.

### Usage

Here is how to build the container. Note that we build so it belongs to the same
namespace as the repository here. "ghcr.io" means "GitHub Container Registry" and
is the [GitHub packages](https://github.com/features/packages) registry that supports
Docker images and other OCI artifacts. From the root of the repository:

```bash
$ docker build -f etc/docker/Dockerfile.base -t ghcr.io/flux-framework/flux-core-base .
```

**More will be added when the final flux container is developed**

0 comments on commit a81100b

Please sign in to comment.