Skip to content

Commit 1e4aa00

Browse files
committed
chore: revise versioning handling in docker build and Circleci
1 parent 78ab237 commit 1e4aa00

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.circleci/config.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,22 @@ jobs:
4141
docker push localhost:5000/ubuntu
4242
fi
4343
- checkout
44+
- run:
45+
name: Prepare a Python environment
46+
command: |
47+
pyenv local 3.7.0
48+
python3 -m pip install "setuptools ~= 42.0" "setuptools_scm[toml] >= 3.4" "pip>=10.0.1"
4449
- run:
4550
name: Build Docker image & push to registry
4651
no_output_timeout: 60m
4752
command: |
53+
pyenv local 3.7.0
4854
e=1 && for i in {1..5}; do
4955
docker build --rm --cache-from=nitransforms:latest \
5056
-t nitransforms:latest \
5157
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
52-
--build-arg VCS_REF=`git rev-parse --short HEAD` . \
58+
--build-arg VCS_REF=`git rev-parse --short HEAD` \
59+
--build-arg VERSION=$( python3 setup.py --version ) . \
5360
&& e=0 && break || sleep 15
5461
done && [ "$e" -eq "0" ]
5562
docker tag nitransforms:latest localhost:5000/nitransforms
@@ -67,7 +74,6 @@ jobs:
6774
name: Check version packaged in Docker image
6875
command: |
6976
pyenv local 3.7.0
70-
python3 -m pip install "setuptools ~= 42.0" "setuptools_scm[toml] >= 3.4" "pip>=10.0.1"
7177
THISVERSION=${CIRCLE_TAG:-$(python3 setup.py --version)}
7278
INSTALLED_VERSION=$(\
7379
docker run -it --rm --entrypoint=python nitransforms \

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,10 @@ WORKDIR /home/neuro
131131
ENV HOME="/home/neuro"
132132

133133
# Install package
134+
# CRITICAL: Make sure python setup.py --version has been run at least once
135+
# outside the container, with access to the git history.
134136
COPY . /src/nitransforms
135-
ARG VERSION
136-
# Force static versioning within container
137-
RUN echo "${VERSION}" > /src/nitransforms/nitransforms/VERSION && \
138-
echo "include nitransforms/VERSION" >> /src/nitransforms/MANIFEST.in && \
139-
pip install --no-cache-dir "/src/nitransforms[all]"
137+
RUN pip install --no-cache-dir "/src/nitransforms[all]"
140138

141139
RUN find $HOME -type d -exec chmod go=u {} + && \
142140
find $HOME -type f -exec chmod go=u {} +

0 commit comments

Comments
 (0)