Skip to content

Commit

Permalink
docker container and ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer2368 committed Oct 17, 2024
1 parent c029ef6 commit 90b2a92
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI
on:
push:
branches:
- main
workflow_dispatch: {}
pull_request:
types: [opened, synchronize]
branches:
- main

jobs:
docker-image:
uses: ./.github/workflows/docker.yml
api-doc:
needs: [docker-image]
uses: ./.github/workflows/sphinx.yml
69 changes: 69 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: docker-image
on:
workflow_call:

env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: LLNL/GPLaSDI/lasdi_env
DOCKERPATH: docker

jobs:
docker-ci:
runs-on: ubuntu-latest
name: "docker env"
env:
DOCKERPATH: docker
steps:
- name: test command
run: echo "docker-ci command"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: Ana06/[email protected]
id: files
- name: DockerPATH configuration
run: echo "DOCKERPATH=$DOCKERPATH"
- name: DockerPATH - check if files in docker path changed
if: contains(steps.files.outputs.all,env.DOCKERPATH) || contains(steps.files.outputs.all,'docker.yml')
run: |
echo "CI container needs rebuilding..."
echo "CI_NEEDS_REBUILD=true" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
if: env.CI_NEEDS_REBUILD
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
if: env.CI_NEEDS_REBUILD
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=sha
flavor: latest=true
- name: Build Container motd
if: env.CI_NEEDS_REBUILD
run: |
echo "#!/bin/bash" > ${{env.DOCKERPATH}}/motd.sh
echo "echo --------------------------" >> ${{env.DOCKERPATH}}/motd.sh
echo "echo lasdi_env/CI Development Container" >> ${{env.DOCKERPATH}}/motd.sh
echo "echo \"Revision: `echo ${GITHUB_SHA} | cut -c1-8`\"" >> ${{env.DOCKERPATH}}/motd.sh
echo "echo --------------------------" >> ${{env.DOCKERPATH}}/motd.sh
chmod 755 ${{env.DOCKERPATH}}/motd.sh
cat ${{env.DOCKERPATH}}/motd.sh
- name: Docker Image - Build and push
if: env.CI_NEEDS_REBUILD
uses: docker/build-push-action@v5
with:
push: true
context: ${{ env.DOCKERPATH }}
tags: ${{ steps.meta.outputs.tags }}
# platforms: linux/amd64,linux/arm64
platforms: linux/amd64
13 changes: 12 additions & 1 deletion .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
name: "Sphinx: Render docs"

on: push
# on: push
on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/llnl/gplasdi/lasdi_env:latest
options: --user 1001 --privileged
volumes:
- /mnt:/mnt
permissions:
contents: write
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
- name: Build HTML
uses: ammaraskar/sphinx-action@master
Expand Down
36 changes: 36 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:22.04

ENV ENVDIR=env

# install sudo
RUN apt-get -yq update && apt-get -yq install sudo

WORKDIR /$ENVDIR

# install packages
RUN sudo apt-get install -yq git
RUN sudo apt-get install --no-install-recommends -yq make gcc gfortran libssl-dev cmake
RUN sudo apt-get install -yq libopenblas-dev libmpich-dev libblas-dev liblapack-dev libscalapack-mpi-dev libhdf5-mpi-dev hdf5-tools
RUN sudo apt-get install -yq vim
RUN sudo apt-get install -yq git-lfs
RUN sudo apt-get install -yq valgrind
RUN sudo apt-get install -yq wget
RUN sudo apt-get install -yq astyle

# install python
RUN sudo apt-get install -yq python3
RUN sudo apt-get install -yq python3-dev
RUN sudo apt-get install -yq python3-pip
RUN sudo pip3 install --upgrade pip
RUN sudo pip3 install sphinx-autoapi sphinx_rtd_theme
#RUN sudo pip3 install numpy scipy argparse tables PyYAML h5py pybind11 pytest mpi4py merlin
#
RUN sudo apt-get clean -q

# create and switch to a user
ENV USERNAME=test
RUN echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN useradd --no-log-init -u 1001 --create-home --shell /bin/bash $USERNAME
RUN adduser $USERNAME sudo
USER $USERNAME
WORKDIR /home/$USERNAME

0 comments on commit 90b2a92

Please sign in to comment.