Skip to content

Commit 0ba3e51

Browse files
authored
Merge pull request #57 from AlexandrovLab/docker-updates
v1.4.2: Add automated Docker build and publish pipeline
2 parents 4370277 + 4dd1469 commit 0ba3e51

File tree

6 files changed

+62
-12
lines changed

6 files changed

+62
-12
lines changed

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
dist: focal
22
language: python
33

4+
on:
5+
push:
6+
branches:
7+
- master
8+
paths-ignore:
9+
- 'CHANGELOG.md'
10+
- 'README.md'
11+
- 'LICENSE'
12+
413
python:
514
- "3.9"
615
- "3.12"
716

17+
services:
18+
- docker
19+
820
install:
921
- pip install -q matplotlib
1022
- pip install .[tests]
@@ -14,3 +26,30 @@ script:
1426
- python3 sigProfilerPlotting/examples/plot_example.py
1527
# run unit tests
1628
- pytest -s -rw tests
29+
30+
after_success:
31+
- |
32+
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PYTHON_VERSION" == "3.12" ]; then
33+
echo "Starting Docker deployment to Docker Hub..."
34+
35+
# Dynamically get the version from setup.py for the tag
36+
VERSION_TAG=$(grep "VERSION = " setup.py | cut -d'"' -f2)
37+
echo "Building version: $VERSION_TAG for commit: $TRAVIS_COMMIT"
38+
39+
# Log in securely using environment variables from Travis CI settings
40+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
41+
42+
# Build the image, passing the commit SHA and tagging with the version and "latest"
43+
docker build \
44+
--build-arg COMMIT_SHA=$TRAVIS_COMMIT \
45+
-t mdbarnesucsd/sigprofilerplotting:$VERSION_TAG \
46+
-t mdbarnesucsd/sigprofilerplotting:latest .
47+
48+
# Push both tags to your personal Docker Hub account
49+
docker push mdbarnesucsd/sigprofilerplotting:$VERSION_TAG
50+
docker push mdbarnesucsd/sigprofilerplotting:latest
51+
52+
echo "Docker deployment successful"
53+
else
54+
echo "Skipping Docker deployment"
55+
fi

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
## [1.4.2] - 2025-10-13
10+
11+
### Added
12+
- Implemented a CI/CD pipeline with Travis CI to automate the building and publishing of Docker images to Docker Hub.
13+
- Added a `pyproject.toml` file to standardize the package build system.
14+
915
## [1.4.1] - 2025-03-10
1016

1117
### Fixed

Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@ FROM ubuntu:22.04
44
# Avoid prompts from apt
55
ARG DEBIAN_FRONTEND=noninteractive
66

7-
# Install Python and other dependencies, and apply updates
7+
# Install Python, git, and other dependencies, and apply updates
88
RUN apt-get update && apt-get upgrade -y && \
9-
apt-get install -y python3-pip python3-dev && \
9+
apt-get install -y python3-pip python3-dev git && \
1010
apt-get clean && rm -rf /var/lib/apt/lists/*
1111

12+
# Argument to specify the commit, defaults to the 'master' branch
13+
ARG COMMIT_SHA=master
1214

1315
# Set the working directory in the container
1416
WORKDIR /usr/src/app
1517

16-
# Install SigProfilerMatrixGenerator using pip
17-
RUN pip3 install SigProfilerPlotting==1.3.21
18+
# Install the package directly from the specific commit on GitHub
19+
RUN pip3 install 'git+https://github.com/AlexandrovLab/SigProfilerPlotting.git@'${COMMIT_SHA}
1820

19-
# Create a non-root user named 'spm_user'
21+
# Create a non-root user
2022
RUN useradd -m -s /bin/bash spm_user
2123

22-
# Change the ownership of the /usr/src/app directory and its contents to the new non-root user
24+
# Change the ownership of the working directory
2325
RUN chown -R spm_user:spm_user /usr/src/app
2426

25-
# Switch to the non-root user for subsequent commands and when running the container
27+
# Switch to the non-root user for security
2628
USER spm_user

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools>=61", "wheel", "build"]
3+
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def readme():
1414
return f.read()
1515

1616

17-
VERSION = "1.4.1"
17+
VERSION = "1.4.2"
1818

1919

2020
def write_version_py(filename="sigProfilerPlotting/version.py"):
@@ -23,7 +23,7 @@ def write_version_py(filename="sigProfilerPlotting/version.py"):
2323
# THIS FILE IS GENERATED FROM SIGPROFILERPLOTTING SETUP.PY
2424
short_version = '%(version)s'
2525
version = '%(version)s'
26-
update = 'v1.4.1: Update plotSV to use pandas >= 2.0.0.'
26+
update = 'v1.4.2: Add automated Docker build and publish pipeline'
2727
2828
"""
2929
fh = open(filename, "w")

sigProfilerPlotting/version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# THIS FILE IS GENERATED FROM SIGPROFILERPLOTTING SETUP.PY
3-
short_version = '1.4.1'
4-
version = '1.4.1'
5-
update = 'v1.4.1: Update plotSV to use pandas >= 2.0.0.'
3+
short_version = '1.4.2'
4+
version = '1.4.2'
5+
update = 'v1.4.2: Add automated Docker build and publish pipeline'
66

77

0 commit comments

Comments
 (0)