diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..0eba8ed --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,265 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "main", DEV-932 ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + + LITMAPPER_BACKEND_IMAGE_NAME: USEPA/litmapper-backend + LITMAPPER_ETL_IMAGE_NAME: USEPA/litmapper-etl + LITMAPPER_FRONTEND_IMAGE_NAME: USEPA/litmapper-frontend + LITMAPPER_SPECTER_IMAGE_NAME: USEPA/litmapper-specter + + +jobs: + backend-build-push: + + runs-on: ubuntu-latest + environment: ${{ github.head_ref || github.ref_name }} + permissions: + contents: write + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: USEPA + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.LITMAPPER_BACKEND_IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v4 + with: + context: ./backend/ + file: ./backend/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + # Removing old packages and only keeping 3 untagged versions + - name: Delete Package Versions + uses: actions/delete-package-versions@v5 + with: + package-name: litmapper-backend + package-type: 'container' + min-versions-to-keep: 3 + delete-only-untagged-versions: 'true' + + etl-build-push: + + runs-on: th874 + environment: ${{ github.head_ref || github.ref_name }} + permissions: + contents: write + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: USEPA + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env. LITMAPPER_ETL_IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v4 + with: + context: ./etl/ + file: ./etl/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + # Removing old packages and only keeping 3 untagged versions + - name: Delete Package Versions + uses: actions/delete-package-versions@v5 + with: + package-name: litmapper-etl + package-type: 'container' + min-versions-to-keep: 3 + delete-only-untagged-versions: 'true' + + frontend-build-push: + runs-on: ubuntu-latest + environment: ${{ github.head_ref || github.ref_name }} + permissions: + contents: write + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Create .env file for build + - name: Creating .env file + run: echo "$ENV_TEXT" > ./frontend/.env + env: + ENV_TEXT: ${{vars.ENV_TEXT}} + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: USEPA + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.LITMAPPER_FRONTEND_IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: ./frontend/ + file: ./frontend/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + # Removing old packages and only keeping 3 untagged versions + - name: Delete Package Versions + uses: actions/delete-package-versions@v5 + with: + package-name: litmapper-frontend + package-type: 'container' + min-versions-to-keep: 3 + delete-only-untagged-versions: 'true' + + specter-build-push: + runs-on: ubuntu-latest + environment: ${{ github.head_ref || github.ref_name }} + permissions: + contents: write + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: USEPA + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.LITMAPPER_SPECTER_IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: ./specter/ + file: ./specter/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + # Removing old packages and only keeping 3 untagged versions + - name: Delete Package Versions + uses: actions/delete-package-versions@v5 + with: + package-name: litmapper-specter + package-type: 'container' + min-versions-to-keep: 3 + delete-only-untagged-versions: 'true' + diff --git a/etl/Dockerfile b/etl/Dockerfile index 6c438ea..22913de 100644 --- a/etl/Dockerfile +++ b/etl/Dockerfile @@ -6,7 +6,7 @@ RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machi RUN apt-get update && apt-get install -y \ git libhdf5-dev \ && rm -rf /var/lib/apt/lists/* - + COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache numpy==1.26.4 \ && pip install --no-cache Cython==0.29.37 \ diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 05e6a60..0797fe8 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,6 +1,7 @@ FROM node:20.13.1-slim WORKDIR /code +COPY . /code COPY ./package.json ./package-lock.json ./ RUN npm install diff --git a/specter/Dockerfile b/specter/Dockerfile index 81f46b8..7106655 100644 --- a/specter/Dockerfile +++ b/specter/Dockerfile @@ -4,3 +4,5 @@ WORKDIR /code COPY ./requirements.txt /code/requirements.txt RUN pip install -r /code/requirements.txt + +