Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(docker): add Dockerfile and container image build tests #362

Merged
merged 6 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,22 @@ jobs:
# For every other version and/or OS, run pytest without coverage
if: (matrix.os != 'ubuntu-latest') || (matrix.python-version != env.TARGET_PYTHON_VERSION )
run: poetry run pytest ${{ github.event.inputs.pytest_addopts }}
docker-image-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
d33bs marked this conversation as resolved.
Show resolved Hide resolved
# note: roughly follows Docker documentation on GitHub Actions usage
# found on the following https://github.com/docker/build-push-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Try to build docker image
run: |
docker build -f build/docker/Dockerfile -t pycytominer:latest .
- name: Run tests through docker image
run: |
docker run pycytominer:latest poetry run pytest
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ repos:
rev: v1.6.26
hooks:
- id: actionlint
- repo: https://github.com/hadolint/hadolint
rev: v2.12.1-beta
hooks:
- id: hadolint-docker
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ help:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# note: presumes the existence of docker daemon to receive docker commands
test_docker_build:
docker build -f build/docker/Dockerfile -t pycytominer:latest . && \
docker run pycytominer:latest poetry run pytest
31 changes: 31 additions & 0 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM python:3.11

# set various metadata, loosely following biocontainers standards from:
# https://biocontainers-edu.readthedocs.io/en/latest/what_is_biocontainers.html
LABEL base_image="python:3.11"
LABEL software="pycytominer"
LABEL about.summary="Python package for processing image-based profiling data"
LABEL about.home="https://github.com/cytomining/pycytominer"
LABEL about.documentation="https://pycytominer.readthedocs.io/en/stable/"
LABEL about.license_file="https://github.com/cytomining/pycytominer/blob/main/LICENSE.md"
LABEL about.license="SPDX:BSD-3-Clause"

# set the workdir to /app
WORKDIR /app

# copy pyproject and poetry lockfile for stepped installation
COPY pyproject.toml poetry.lock ./

# install poetry and poetry dynamic versioning
# hadolint ignore=DL3013
RUN pip install --no-cache-dir poetry poetry-dynamic-versioning

# copy the rest of the repository
COPY . .

# install pycytominer from poetry with group deps and all extras
RUN poetry install --with dev,docs --all-extras -v --no-interaction
d33bs marked this conversation as resolved.
Show resolved Hide resolved

# set an alias for running python through the poetry env of pycytominer
# hadolint ignore=DL3059
RUN echo 'alias python="poetry run python"' >> ~/.bashrc
d33bs marked this conversation as resolved.
Show resolved Hide resolved