Skip to content

Commit 79d0eb9

Browse files
authored
Merge pull request #14 from NCI-GDC/feat/multistage-build-test
Feat/multistage build test
2 parents 0762f53 + 06c2253 commit 79d0eb9

File tree

4 files changed

+48
-72
lines changed

4 files changed

+48
-72
lines changed

Dockerfile.multistage

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM quay.io/ncigdc/bio-python:3.6 as builder
2+
3+
COPY ./ /opt
4+
5+
WORKDIR /opt
6+
7+
RUN python3 setup.py build \
8+
&& mkdir -p dist/ \
9+
&& cp -r build/lib/* dist/ \
10+
&& cp -r bin/ dist/ \
11+
&& cp -f Makefile requirements.txt dev-requirements.txt README.md setup.py dist/
12+
13+
FROM quay.io/ncigdc/bio-python:3.6
14+
15+
COPY --from=builder /opt/dist/ /opt
16+
17+
ENV BINARY=aliquotmaf
18+
19+
WORKDIR /opt
20+
21+
RUN python3 -m pip install -r requirements.txt -r dev-requirements.txt \
22+
&& python3 setup.py develop \
23+
&& ln -s /opt/bin/${BINARY} /bin/${BINARY} \
24+
&& chmod +x /bin/${BINARY}
25+
26+
ENTRYPOINT ["/bin/aliquotmaf"]
27+
28+
CMD ["--help"]

Jenkinsfile

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,13 @@ pipeline {
1717
TWINE_PASSWORD = credentials('twine_password')
1818
QUAY_USERNAME = credentials('QUAY_USERNAME')
1919
QUAY_PASSWORD = credentials('QUAY_PASSWORD')
20-
http_proxy = "$PROXY"
21-
https_proxy = "$PROXY"
2220
}
2321
options {
2422
disableConcurrentBuilds()
2523
skipStagesAfterUnstable()
2624
}
2725

2826
stages {
29-
stage('Init') {
30-
steps {
31-
vbash 'make version'
32-
33-
script {
34-
GIT_HASH = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
35-
VERSION = sh(script: "make print-version BRANCH_NAME=${BRANCH_NAME}", returnStdout: true).trim()
36-
PYPI_VERSION = sh(script: "make print-pypi", returnStdout: true).trim()
37-
currentBuild.displayName = "#${currentBuild.number} - ${VERSION}"
38-
}
39-
40-
echo "Version: ${VERSION}"
41-
}
42-
}
4327
stage('Docker Build') {
4428
steps {
4529
vbash "make build-docker PROXY=${PROXY}"
@@ -50,44 +34,18 @@ pipeline {
5034
sh 'make test-docker'
5135
}
5236
}
53-
stage('Docker Publish Staging') {
54-
when {
55-
anyOf {
56-
branch 'feat*'
57-
branch 'develop'
58-
branch 'hotfix/*'
59-
branch 'release/*'
60-
}
61-
}
37+
stage('Docker Publish') {
6238
steps {
63-
sh 'make publish-staging'
64-
}
65-
}
66-
stage('Docker Publish Release') {
67-
when {
68-
anyOf {
69-
branch 'main'
39+
script {
40+
DOCKER_TAG = sh(script: "make version-docker-tag", returnStdout: true).trim()
7041
}
71-
}
72-
steps {
73-
sh 'make publish-release'
42+
sh "make publish-docker DOCKER_TAG=${DOCKER_TAG}"
7443
}
7544
}
76-
stage('PyPI Publish Branch') {
77-
when {
78-
anyOf {
79-
branch 'main'
80-
branch 'develop'
81-
branch 'hotfix/*'
82-
branch 'release/*'
83-
}
84-
}
85-
steps {
86-
echo "Building PyPI Version: ${PYPI_VERSION}"
87-
sh "pip install --user twine wheel"
88-
vbash "make build-pypi"
89-
vbash "make publish-pypi"
90-
}
45+
}
46+
post {
47+
always {
48+
sh 'make clean'
9149
}
9250
}
9351
}

Makefile

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
# UPDATE ME
21
REPO = aliquot-maf-tools
32

4-
# UPDATE ME
53
MODULE = aliquotmaf
64

7-
GIT_SHORT_HASH:=$(shell git rev-parse --short HEAD)
8-
9-
PYPI_VERSION:=$(shell python3 setup.py -q print_version --pypi)
10-
DOCKER_VERSION:=$(shell python3 setup.py -q print_version --docker)
11-
COMMIT_HASH:=$(shell python3 setup.py -q print_version --hash)
5+
COMMIT_HASH:=$(shell git rev-parse HEAD 2>/dev/null)
126

137
DOCKER_REPO := quay.io/ncigdc
14-
DOCKER_IMAGE := ${DOCKER_REPO}/${REPO}:${DOCKER_VERSION}
158
DOCKER_IMAGE_COMMIT := ${DOCKER_REPO}/${REPO}:${COMMIT_HASH}
169
DOCKER_IMAGE_LATEST := ${DOCKER_REPO}/${REPO}:latest
1710

18-
TWINE_REPOSITORY_URL?=""
11+
TWINE_REPOSITORY_URL?=
1912
PIP_EXTRA_INDEX_URL?=
2013

2114
.PHONY: version version-* print-*
2215
version:
2316
@echo --- VERSION: ${PYPI_VERSION} ---
2417

2518
version-docker:
26-
@echo ${DOCKER_IMAGE}
27-
@echo ${DOCKER_IMAGE_COMMIT}
19+
@python setup.py -q print_version --docker
20+
21+
version-docker-tag:
22+
@docker run --rm --entrypoint="make" ${DOCKER_IMAGE_LATEST} "version-docker"
2823

2924
.PHONY: docker-login
3025
docker-login:
@@ -87,17 +82,11 @@ build: build-docker
8782
build-docker:
8883
@echo
8984
@echo -- Building docker --
90-
python3 setup.py build
91-
mkdir -p dist
92-
cp -r build/lib/* dist/
93-
cp -r bin/ dist/
94-
cp -f Makefile requirements.txt dev-requirements.txt README.md setup.py dist/
9585
docker build . \
96-
--file ./Dockerfile \
86+
--file ./Dockerfile.multistage \
9787
--build-arg http_proxy=${PROXY} \
9888
--build-arg https_proxy=${PROXY} \
9989
-t "${DOCKER_IMAGE_COMMIT}" \
100-
-t "${DOCKER_IMAGE}" \
10190
-t "${DOCKER_IMAGE_LATEST}"
10291

10392
build-pypi:
@@ -121,10 +110,11 @@ test-docker:
121110
@echo -- Running Docker Test --
122111
docker run --rm ${DOCKER_IMAGE_LATEST} test
123112

124-
.PHONY: publish publish-*
125-
publish:
113+
.PHONY: publish-*
114+
publish-docker:
115+
docker tag ${DOCKER_IMAGE_COMMIT} ${DOCKER_REPO}/${REPO}:${DOCKER_TAG}
126116
docker push ${DOCKER_IMAGE_COMMIT}
127-
docker push ${DOCKER_IMAGE}
117+
docker push ${DOCKER_REPO}/${REPO}:${DOCKER_TAG}
128118

129119
publish-pypi: dist/*.whl
130120
@echo

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
GIT_REPO_URL = "https://github.com/NCI-GDC/{}".format(GIT_REPO)
1616

1717
INSTALL_REQUIRES = [
18-
"bioinf-maflib>=1.1.0",
18+
"bioinf-maflib",
1919
"pysam",
2020
]
2121

0 commit comments

Comments
 (0)