Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrastructure for Container #56

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Docker Container

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: c2sm
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: c2sm/probtest:latest
platforms: linux/amd64,linux/arm64
outputs: type=oci,dest=probtest_image.tar

- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4
with:
name: probtest_image.tar
path: probtest_image.tar
59 changes: 59 additions & 0 deletions .github/workflows/deploy-container-for-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy image to DockerHub and GitHub Release

on:
push:
tags:
- '*'

jobs:
build_and_release:
runs-on: ubuntu-latest

steps:
- name: Set up Git repository
uses: actions/checkout@v2
with:
submodules: true # Checkout submodules

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: c2sm
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Save Docker image
id: build_docker_image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: c2sm/probtest:${{ github.ref_name }}
platforms: linux/amd64,linux/arm64
outputs: type=oci,dest=probtest_image.tar

- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4
with:
name: probtest_image.tar
path: probtest_image.tar

- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: probtest_image.tar
asset_name: probtest_image.tar
asset_content_type: application/x-tar
8 changes: 1 addition & 7 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: Run Pytest in probtest

on:
push:
branches:
- main
pull_request:
branches:
- main
on: [push]

jobs:
probtest-pytest:
Expand Down
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Use the official Ubuntu base image
FROM ubuntu:latest

# Set environment variables
ENV TZ=Europe/Zurich

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
wget \
bzip2 \
ca-certificates \
curl \
git \
# Install tzdata to set the timezone, otherwise timing tests of probtest will fail with
# ValueError: time data 'Sun Jun 26 20:11:23 CEST 2022' does not match format '%a %b %d %H:%M:%S %Z %Y'
tzdata \
&& apt-get clean


COPY . /probtest
RUN cd /probtest && ./setup_miniconda.sh -p /opt/conda
# Add conda to PATH
ENV PATH=/opt/conda/miniconda/bin:$PATH

# only unpinned env works on aarch64
RUN ARCH=$(uname -m) && \
cd /probtest && chmod +x /probtest/setup_env.sh && \
if [ "$ARCH" = "aarch64" ]; then \
./setup_env.sh -u -n probtest; \
else \
./setup_env.sh -n probtest; \
fi

# Test probtest
RUN cd /probtest && conda run --name probtest pytest -v -s --cov --cov-report=term tests/

# Set the working directory
WORKDIR /probtest

SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["conda", "run", "--name", "probtest", "/bin/bash", "-c"]
1 change: 1 addition & 0 deletions setup_miniconda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if [[ -f $CONDA_EXE ]]; then
echo "Found a conda executable at: ${CONDA_EXE}"
else
echo "No conda executable available, fetching Miniconda install script"
mkdir -p ${INSTALL_PREFIX}
wget -O ${INSTALL_PREFIX}/miniconda.sh ${MINICONDA_URL}
echo "${SHA256} ${INSTALL_PREFIX}/miniconda.sh" | sha256sum --check || exit 1
bash ${INSTALL_PREFIX}/miniconda.sh -b -p ${INSTALL_PREFIX}/miniconda
Expand Down
Loading