-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from fetch4/37_regular_docker_build
Set up regular Docker build
- Loading branch information
Showing
4 changed files
with
84 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Periodic Docker build | ||
|
||
on: | ||
# Build the Docker container whenever commits are pushed to an open PR that changes one of the files listed | ||
pull_request: | ||
paths: | ||
- .github/workflows/docker.yml | ||
- docker/Dockerfile.devenv | ||
- docker/spack.yaml | ||
|
||
# Build the Docker container at 00:00 on the first day of every 3 months | ||
schedule: | ||
- cron: '0 0 1 */3 *' | ||
|
||
jobs: | ||
docker: | ||
name: Build Docker container | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log into GitHub Container Repository | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
logout: true | ||
|
||
- name: Build container and push to ghcr | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
file: docker/Dockerfile.devenv | ||
tags: ghcr.io/fetch4/giss-gc-dev-env:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,18 @@ | ||
# Build stage with Spack pre-installed and ready to be used | ||
FROM spack/ubuntu-jammy:0.21 AS builder | ||
|
||
# What we want to install and how we want to install it | ||
# is specified in a manifest file (spack.yaml) | ||
RUN mkdir /opt/spack-environment \ | ||
&& (echo spack: \ | ||
&& echo ' packages:' \ | ||
&& echo ' all:' \ | ||
&& echo ' compiler: [[email protected]]' \ | ||
&& echo ' specs:' \ | ||
&& echo ' - [email protected]' \ | ||
&& echo ' - gmake' \ | ||
&& echo ' - [email protected]' \ | ||
&& echo ' - [email protected]+mpi+parallel-netcdf' \ | ||
&& echo ' - netcdf-fortran' \ | ||
&& echo ' - [email protected]' \ | ||
&& echo ' concretizer:' \ | ||
&& echo ' unify: true' \ | ||
&& echo ' config:' \ | ||
&& echo ' install_missing_compilers: true' \ | ||
&& echo ' install_tree: /opt/software' \ | ||
&& echo ' view: /opt/views/view') > /opt/spack-environment/spack.yaml | ||
|
||
# Install the software, remove unnecessary deps | ||
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast && spack gc -y | ||
# Install software from spack.yaml | ||
RUN mkdir /opt/spack-environment | ||
COPY docker/spack.yaml /opt/spack-environment/spack.yaml | ||
RUN cd /opt/spack-environment \ | ||
&& spack env activate . \ | ||
&& spack install --fail-fast \ | ||
&& spack gc -y | ||
|
||
# Install perl URI lib | ||
RUN apt update && apt install -y libany-uri-escape-perl | ||
RUN apt update \ | ||
&& apt install -y --no-install-recommends libany-uri-escape-perl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Strip all the binaries | ||
RUN find -L /opt/views/view/* -type f -exec readlink -f '{}' \; | \ | ||
|
@@ -36,27 +22,31 @@ RUN find -L /opt/views/view/* -type f -exec readlink -f '{}' \; | \ | |
awk -F: '{print $1}' | xargs strip | ||
|
||
# Modifications to the environment that are necessary to run | ||
RUN cd /opt/spack-environment && \ | ||
spack env activate --sh -d . > activate.sh | ||
RUN cd /opt/spack-environment \ | ||
&& spack env activate --sh -d . > activate.sh | ||
|
||
# Bare OS image to run the installed executables | ||
FROM ubuntu:22.04 | ||
|
||
# Copy necessary files from the builder stage | ||
COPY --from=builder /opt/spack-environment /opt/spack-environment | ||
COPY --from=builder /opt/software /opt/software | ||
COPY --from=builder /usr /usr | ||
|
||
# paths.view is a symlink, so copy the parent to avoid dereferencing and duplicating it | ||
COPY --from=builder /opt/views /opt/views | ||
|
||
# Create entrypoint script | ||
RUN { \ | ||
echo '#!/bin/sh' \ | ||
&& echo '.' /opt/spack-environment/activate.sh \ | ||
&& echo 'exec "$@"'; \ | ||
echo '#!/bin/sh'; \ | ||
echo '. /opt/spack-environment/activate.sh'; \ | ||
echo 'exec "$@"'; \ | ||
} > /entrypoint.sh \ | ||
&& chmod a+x /entrypoint.sh \ | ||
&& ln -s /opt/views/view /opt/view \ | ||
&& apt update && apt install -y ca-certificates cpp m4 | ||
&& chmod a+x /entrypoint.sh \ | ||
&& ln -s /opt/views/view /opt/view \ | ||
&& apt update \ | ||
&& apt install -y --no-install-recommends ca-certificates cpp m4 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set entrypoint and default command | ||
ENTRYPOINT [ "/entrypoint.sh" ] | ||
CMD [ "/bin/bash" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
spack: | ||
packages: | ||
all: | ||
compiler: [[email protected]] | ||
specs: | ||
- cmake | ||
- gmake | ||
- hdf5 | ||
- netcdf-c+mpi+parallel-netcdf | ||
- netcdf-fortran | ||
- openmpi | ||
concretizer: | ||
unify: true | ||
config: | ||
install_missing_compilers: true | ||
install_tree: /opt/software | ||
view: /opt/views/view |