From 2beecec8c561abd8baeec6958bd1a0900dc63d22 Mon Sep 17 00:00:00 2001 From: Chris Rowe Date: Mon, 29 Jul 2024 22:30:12 +0000 Subject: [PATCH] container v0.1 --- .devcontainer/Dockerfile | 2 -- .github/workflows/build-image.yml | 45 +++++++++++++++++++++++++++++++ container/Containerfile | 8 ++++++ container/VERSION | 1 + 4 files changed, 54 insertions(+), 2 deletions(-) delete mode 100644 .devcontainer/Dockerfile create mode 100644 .github/workflows/build-image.yml create mode 100644 container/Containerfile create mode 100644 container/VERSION diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 13045d1..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM mcr.microsoft.com/devcontainers/python:0-3.10 -RUN pip install --upgrade pip \ No newline at end of file diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..86492bc --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,45 @@ +name: build-image +on: + push: + branches: + - main + paths: + - container/Containerfile + - container/VERSION + - environment.yml +jobs: + build-image: + name: build-image + runs-on: ubuntu-22.04 + steps: + - name: Clean up Ubuntu + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get VERSION + run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV + - name: Build Image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: wri-cities-cif-environment + tags: latest ${{ env.VERSION }} ${{ github.sha }} + containerfiles: | + ./Containerfile + - name: Push image to container registry + id: push-image-to-registry + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build-image.outputs.image }} + tags: ${{ steps.build-image.outputs.tags }} + registry: ghcr.io/wri + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - name: Print image url + run: echo "Image pushed to ${{ steps.push-image-to-registry.outputs.registry-paths }}" \ No newline at end of file diff --git a/container/Containerfile b/container/Containerfile new file mode 100644 index 0000000..491ed8c --- /dev/null +++ b/container/Containerfile @@ -0,0 +1,8 @@ +FROM condaforge/miniforge3:latest +LABEL maintainer="Chris Rowe" +WORKDIR /src/ +COPY environment.yml . +RUN true && \ + mamba env create -f environment.yml && \ + echo "source activate cities-cif" > "$HOME/.bashrc" +ENV PATH "/src:/opt/conda/envs/cities-cif/bin:$PATH" \ No newline at end of file diff --git a/container/VERSION b/container/VERSION new file mode 100644 index 0000000..ceab6e1 --- /dev/null +++ b/container/VERSION @@ -0,0 +1 @@ +0.1 \ No newline at end of file