Skip to content

Commit

Permalink
Add Docker build config and continuous delivery
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisher87 committed Jul 24, 2024
1 parent 4df6c02 commit eea3a51
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Build & publish artifacts"

on:
push:
branches:
- "main"
- "v2" # TODO: Remove before merge!
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3

jobs:
# build-python-package:
# name: Build Python package
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - uses: hynek/build-and-inspect-python-package@v2

# publish-python-package:
# name: Publish Python package to PyPI
# if: github.ref_type == 'tag'
# needs: ["build-python-package"]
# runs-on: ubuntu-latest
# environment: pypi
# permissions:
# id-token: write
# steps:
# - uses: actions/download-artifact@v4
# with:
# name: Packages
# path: dist

# - uses: pypa/gh-action-pypi-publish@release/v1
# if: github.event_name == 'release' && github.event.action == 'published'
# with:
# # Remember to tell (test-)pypi about this repo before publishing
# # Remove this line to publish to PyPI
# repository-url: https://test.pypi.org/legacy/

build-and-publish-docker-image:
name: "Build and publish Docker image"
uses: "nsidc/.github/.github/workflows/build-and-publish-container-image.yml@main"
secrets: "inherit"
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM mambaorg/micromamba:1.5.8-alpine3.20

WORKDIR /app

# Activate the conda environment during build process
ARG MAMBA_DOCKERFILE_ACTIVATE=1

COPY ./conda-lock.yml .

# NOTE: `-p` is important to install to the "base" env
RUN micromamba install -y \
-p /opt/conda \
-f conda-lock.yml \
&& micromamba clean --all --yes


# Install source
COPY ./pyproject.toml .
COPY ./antarctica_today ./antarctica_today
COPY ./qgis ./qgis

# TODO: `pip install --editable .`
ENV PYTHONPATH=.

# Extend the default micromamba entrypoint to use our CLI
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "python", "antarctica_today"]
11 changes: 11 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
cli:
image: "nsidc/antarctica_today:local"
build: "."
user: "root"
volumes:
- "./Tb/:/app/Tb/"
- "./data/:/app/data/"
- "./database/:/app/database/"
- "./plots/:/app/plots/"
- "./baseline_datasets/:/app/baseline_datasets/:ro"
10 changes: 10 additions & 0 deletions doc/operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,13 @@ python antarctica_today process
- [ ] After this step, `git status` shows changed files. Should they be committed?

</details>


## Running in Docker

This repository includes a `compose.yml` configuration which enables running this code
with Docker. For example, the `download-tb` command can be run as follows:

```bash
docker compose run cli download-tb
```

0 comments on commit eea3a51

Please sign in to comment.