Skip to content

Commit

Permalink
feat(containers): Containerize some of Jacob's scripts (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
devsjc authored May 14, 2024
1 parent 7d4ca37 commit 60036c3
Show file tree
Hide file tree
Showing 5 changed files with 831 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build Containers

on:
push:
branches: []
paths-ignore:
- 'README.md'

# Registry for storing Container images
env:
REGISTRY: ghcr.io

jobs:
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: test-unit
if: github.event_name != 'pull_request'
strategy:
matrix:
include:
- folder: .containers/icon
image: ${{ env.REGISTRY }}/icon-etl

steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Container
id: meta
uses: docker/metadata-action
with:
images: ${{ matrix.image }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: $${{ matrix.folder }}
file: ${{ matrix.folder }}/Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

20 changes: 20 additions & 0 deletions containers/icon/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Build a virtualenv using the appropriate Debian release
# * Install python3-venv for the built-in Python3 venv module (not installed by default)
# * Install gcc libpython3-dev to compile C Python modules
# * In the virtualenv: Update pip setuputils and wheel to support building new packages
FROM debian:11-slim AS build
RUN apt-get update && \
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \
python3 -m venv /venv && \
/venv/bin/pip install --upgrade pip setuptools wheel

# Build the virtualenv
FROM build AS build-venv
RUN /venv/bin/python -m pip install zarr xarray ocf_blosc2 huggingface_hub requests

# Copy the virtualenv into a distroless image
FROM gcr.io/distroless/python3-debian11
COPY --from=build-venv /venv /venv
COPY . /app
WORKDIR /app
ENTRYPOINT ["/venv/bin/python3", "main.py"]
Loading

0 comments on commit 60036c3

Please sign in to comment.