diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..26e10cb --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,34 @@ +name: Publish Docker image for latest release + +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image for released version to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v1.13.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3.6.2 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/protopipe-ctadirac + + - name: Build and push Docker image + uses: docker/build-push-action@v2.9.0 + with: + context: ./containers/Docker/Development + file: ./containers/Docker/Release/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker_dev.yml b/.github/workflows/docker_dev.yml new file mode 100644 index 0000000..f10d44e --- /dev/null +++ b/.github/workflows/docker_dev.yml @@ -0,0 +1,35 @@ +name: Publish Docker image for development version + +on: + push: + branches: + - master + +jobs: + push_to_registry: + name: Push Docker image for development version to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v1.13.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3.6.2 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/protopipe-ctadirac-dev + + - name: Build and push Docker image + uses: docker/build-push-action@v2.9.0 + with: + context: ./containers/Docker/Development + file: ./containers/Docker/Development/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/containers/Docker/Development/Dockerfile b/containers/Docker/Development/Dockerfile index 574eec8..923e2d3 100644 --- a/containers/Docker/Development/Dockerfile +++ b/containers/Docker/Development/Dockerfile @@ -3,7 +3,7 @@ # =============================================================================== # Define base image -FROM centos:8 +FROM fedora:latest # Define labels LABEL version="0.1" \ @@ -45,28 +45,7 @@ RUN echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.profile \ conda install mamba -n base -c conda-forge \ && mamba update --all -# =============================================================================== -# PROTOPIPE GRID INTERFACE -# =============================================================================== - -# Get latest environment file and create environment -# WARNING: in the final Dockerfile the pull must come from either the -# master branch (development version) or from a tagged release (released version) -WORKDIR /home/cta/protopipe-grid-interface -RUN git clone https://github.com/HealthyPear/protopipe-grid-interface.git .\ - && git pull origin pull/50/head \ - && mamba env create -f environment_development.yaml \ - && echo "conda activate protopipe-CTADIRAC-dev" >> ~/.bashrc \ - && echo "alias ls='ls --color'" >> ~/.bashrc - -# =============================================================================== -# PROTOPIPE -# =============================================================================== - -# Clone protopipe and install dev version -WORKDIR /home/cta/protopipe -RUN git clone https://github.com/cta-observatory/protopipe.git .\ - && pip install -e '.[all]' - WORKDIR /home/cta/ +RUN echo "alias ls='ls --color'" >> ~/.bashrc + ENTRYPOINT ["bash"] \ No newline at end of file diff --git a/containers/Docker/Released version/Dockerfile b/containers/Docker/Release/Dockerfile similarity index 89% rename from containers/Docker/Released version/Dockerfile rename to containers/Docker/Release/Dockerfile index c3a3cc1..ebe7385 100644 --- a/containers/Docker/Released version/Dockerfile +++ b/containers/Docker/Release/Dockerfile @@ -3,7 +3,7 @@ # =============================================================================== # Define base image -FROM centos:8 +FROM fedora:latest # Define labels LABEL version="0.1" \ @@ -54,9 +54,13 @@ RUN echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.profile \ # master branch (development version) or from a tagged release (released version) WORKDIR /home/cta/protopipe-grid-interface RUN git clone https://github.com/HealthyPear/protopipe-grid-interface.git \ - && git pull origin pull/50/head \ + && git fetch --tags \ + && latestTag=$(git describe --tags `git rev-list --tags --max-count=1`) \ + && git checkout $latestTag \ && mamba env create -f environment_release.yaml \ - && echo "conda activate protopipe-CTADIRAC-dev" >> ~/.bashrc \ + && conda activate protopipe-CTADIRAC \ + && pip install '.[all]' \ + && echo "conda activate protopipe-CTADIRAC" >> ~/.bashrc \ && echo "alias ls='ls --color'" >> ~/.bashrc WORKDIR /home/cta/ diff --git a/environment_release.yaml b/environment_release.yaml index 713386b..b300c0c 100644 --- a/environment_release.yaml +++ b/environment_release.yaml @@ -1,4 +1,4 @@ -name: protopipe-CTADIRAC-latest-release +name: protopipe-CTADIRAC channels: - conda-forge dependencies: @@ -17,4 +17,3 @@ dependencies: - pip: - protopipe - CTADIRAC - - git+https://github.com/HealthyPear/protopipe-grid-interface@v0.4.0