Skip to content

Commit ff850be

Browse files
authored
Merge pull request reactioncommerce#33 from reactioncommerce/new-versioning
Update source for new versioning
2 parents 3286942 + ac6e24b commit ff850be

File tree

11 files changed

+232
-95
lines changed

11 files changed

+232
-95
lines changed

.circleci/bin/build

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -e
3+
4+
declare options_files="${*:-versions/**/options}"
5+
6+
for file in $options_files; do
7+
(
8+
source "$file"
9+
VERSION_DIR="${file%/*}"
10+
mkdir -p docker-cache/images
11+
12+
docker build \
13+
--build-arg "METEOR_VERSION=$METEOR_VERSION" \
14+
--build-arg "BUILD_COMPARE_URL=$CIRCLE_COMPARE_URL" \
15+
--build-arg "BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
16+
--build-arg "BUILD_ENV=test" \
17+
--build-arg "BUILD_NUMBER=$CIRCLE_BUILD_NUM" \
18+
--build-arg "BUILD_PLATFORM=circleci" \
19+
--build-arg "BUILD_PLATFORM_PROJECT_REPONAME=$CIRCLE_PROJECT_REPONAME" \
20+
--build-arg "BUILD_PLATFORM_PROJECT_USERNAME=$CIRCLE_PROJECT_USERNAME" \
21+
--build-arg "BUILD_PULL_REQUESTS=$CI_PULL_REQUESTS" \
22+
--build-arg "BUILD_TRIGGERED_BY_TAG=$CIRCLE_TAG" \
23+
--build-arg "BUILD_URL=$CIRCLE_BUILD_URL" \
24+
--build-arg "CIRCLE_WORKFLOW_ID=$CIRCLE_WORKFLOW_ID" \
25+
--build-arg "CIRCLE_WORKFLOW_JOB_ID=$CIRCLE_WORKFLOW_JOB_ID" \
26+
--build-arg "CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS=$CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS" \
27+
--build-arg "CIRCLE_WORKSPACE_ID=$CIRCLE_WORKSPACE_ID" \
28+
--build-arg "GIT_REPOSITORY_URL=$CIRCLE_REPOSITORY_URL" \
29+
--build-arg "GIT_SHA1=$CIRCLE_SHA1" \
30+
--build-arg "LICENSE=GPL-3.0-only" \
31+
--build-arg "VCS_REF=$CIRCLE_SHA1" \
32+
--build-arg "VENDOR=Reaction Commerce" \
33+
-t "$DOCKER_REPOSITORY:$CIRCLE_SHA1" "$VERSION_DIR"
34+
35+
for tag in "${TAGS[@]}"; do
36+
docker tag \
37+
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" "$DOCKER_REPOSITORY:$tag"
38+
docker save \
39+
-o "docker-cache/images/$tag" "$DOCKER_REPOSITORY:$tag"
40+
done )
41+
done

.circleci/bin/docker-tags

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,14 @@
11
#!/bin/bash
2-
# outputs each tag we're attaching to this docker image
32
set -e
43

5-
SHA=$1
6-
BRANCH=$2
7-
SHA1=$(git rev-parse --verify "${SHA}")
4+
declare options_files="${*:-versions/**/options}"
85

9-
# Echo to stderr
10-
echoerr() { echo "$@" 1>&2; }
6+
for file in $options_files; do
7+
(
8+
source "$file"
9+
VERSION_DIR="${file%/*}"
1110

12-
# Ensure that git SHA was provided
13-
if [[ -x "${SHA1}" ]]; then
14-
echoerr "Error, no git SHA provided"
15-
exit 1;
16-
fi
17-
18-
# tag with the branch
19-
if [[ -n "${BRANCH}" ]]; then
20-
echo "${BRANCH}"
21-
fi
22-
23-
# Tag with each git tag
24-
git show-ref --tags -d | grep "^${SHA1}" | sed -e 's,.* refs/tags/,,' -e 's/\^{}//' 2> /dev/null \
25-
| xargs -I % \
26-
echo "%"
27-
28-
# Tag with latest if certain conditions are met
29-
if [[ "$BRANCH" == "master" ]]; then
30-
# Check to see if we have a valid `vX.X.X` tag and assign to CURRENT_TAG
31-
CURRENT_TAG=$( \
32-
git show-ref --tags -d \
33-
| grep "^${SHA1}" \
34-
| sed -e 's,.* refs/tags/,,' -e 's/\^{}//' \
35-
| grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" \
36-
| sort \
37-
)
38-
39-
# Find the highest tagged version number
40-
HIGHEST_TAG=$(git --no-pager tag | grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" | sort -r | head -n 1)
41-
42-
# We tag :latest only if
43-
# 1. We have a current tag
44-
# 2. The current tag is equal to the highest tag, OR the highest tag does not exist
45-
if [[ -n "${CURRENT_TAG}" ]]; then
46-
if [[ "${CURRENT_TAG}" == "${HIGHEST_TAG}" ]] || [[ -z "${HIGHEST_TAG}" ]]; then
47-
echo "latest"
48-
fi
49-
fi
50-
fi
11+
for tag in "${TAGS[@]}"; do
12+
echo "$tag"
13+
done )
14+
done

.circleci/config.yml

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,75 +22,37 @@ defaults: &defaults
2222
jobs:
2323
docker-build:
2424
<<: *defaults
25+
parallelism: 2
2526
steps:
2627
- checkout
2728
- setup_remote_docker
28-
- run:
29-
name: Discover Docker Tags
30-
command: |
31-
mkdir -p docker-cache
32-
.circleci/bin/docker-tags "$CIRCLE_SHA1" "$CIRCLE_BRANCH" | sed 's/\//-/g' \
33-
> docker-cache/docker-tags.txt
34-
cat docker-cache/docker-tags.txt
3529
- run:
3630
name: Docker Build
37-
command: |
38-
docker build \
39-
--build-arg "BUILD_COMPARE_URL=$CIRCLE_COMPARE_URL" \
40-
--build-arg "BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
41-
--build-arg "BUILD_ENV=test" \
42-
--build-arg "BUILD_NUMBER=$CIRCLE_BUILD_NUM" \
43-
--build-arg "BUILD_PLATFORM=circleci" \
44-
--build-arg "BUILD_PLATFORM_PROJECT_REPONAME=$CIRCLE_PROJECT_REPONAME" \
45-
--build-arg "BUILD_PLATFORM_PROJECT_USERNAME=$CIRCLE_PROJECT_USERNAME" \
46-
--build-arg "BUILD_PULL_REQUESTS=$CI_PULL_REQUESTS" \
47-
--build-arg "BUILD_TRIGGERED_BY_TAG=$CIRCLE_TAG" \
48-
--build-arg "BUILD_URL=$CIRCLE_BUILD_URL" \
49-
--build-arg "CIRCLE_WORKFLOW_ID=$CIRCLE_WORKFLOW_ID" \
50-
--build-arg "CIRCLE_WORKFLOW_JOB_ID=$CIRCLE_WORKFLOW_JOB_ID" \
51-
--build-arg "CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS=$CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS" \
52-
--build-arg "CIRCLE_WORKSPACE_ID=$CIRCLE_WORKSPACE_ID" \
53-
--build-arg "GIT_REPOSITORY_URL=$CIRCLE_REPOSITORY_URL" \
54-
--build-arg "GIT_SHA1=$CIRCLE_SHA1" \
55-
--build-arg "LICENSE=GPL-3.0-only" \
56-
--build-arg "VCS_REF=$CIRCLE_SHA1" \
57-
--build-arg "VENDOR=Reaction Commerce" \
58-
-t "$DOCKER_REPOSITORY:$CIRCLE_SHA1" .
59-
mkdir -p docker-cache
60-
docker save \
61-
-o docker-cache/docker-image.tar \
62-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1"
31+
command: .circleci/bin/build $(circleci tests glob versions/**/options | circleci tests split)
6332
- persist_to_workspace:
6433
root: docker-cache
6534
paths:
66-
- docker-image.tar
67-
- docker-tags.txt
35+
- images/*
6836

6937
docker-push:
7038
<<: *defaults
7139
steps:
40+
- checkout
7241
- setup_remote_docker
7342
- attach_workspace:
7443
at: docker-cache
7544
- run:
7645
name: Load Docker Image
7746
command: |
78-
docker load < docker-cache/docker-image.tar
79-
- run:
80-
name: Tag Docker Image
81-
command: |
82-
cat docker-cache/docker-tags.txt \
47+
.circleci/bin/docker-tags \
8348
| xargs -t -I % \
84-
docker tag \
85-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
86-
"$DOCKER_REPOSITORY:%"
49+
docker load --input docker-cache/images/%
8750
- run:
8851
name: Docker Push
8952
command: |
9053
if [ -z "$CIRCLE_PR_USERNAME" ]; then \
9154
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
92-
docker push "$DOCKER_REPOSITORY:$CIRCLE_SHA1"
93-
cat docker-cache/docker-tags.txt \
55+
.circleci/bin/docker-tags \
9456
| xargs -t -I % \
9557
docker push "$DOCKER_REPOSITORY:%"
9658
else
@@ -100,18 +62,23 @@ jobs:
10062
test:
10163
<<: *defaults
10264
steps:
65+
- checkout
10366
- setup_remote_docker
10467
- attach_workspace:
10568
at: docker-cache
10669
- run:
10770
name: Load Docker Image
10871
command: |
109-
docker load < docker-cache/docker-image.tar
72+
.circleci/bin/docker-tags \
73+
| xargs -t -I % \
74+
docker load --input docker-cache/images/%
11075
- run:
11176
name: Test installed dependencies
11277
command: |
78+
.circleci/bin/docker-tags \
79+
| xargs -t -I % \
11380
docker run --rm \
114-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
81+
"$DOCKER_REPOSITORY:%" \
11582
bash test-script.sh
11683
11784
dockerfile-lint:
@@ -124,7 +91,7 @@ jobs:
12491
- run:
12592
name: Dockerfile Lint
12693
command: |
127-
hadolint Dockerfile
94+
echo versions/**/Dockerfile | xargs -t -n 1 hadolint
12895
12996
13097
workflows:
@@ -139,6 +106,10 @@ workflows:
139106
requires:
140107
- docker-build
141108
- test
109+
filters:
110+
branches:
111+
only:
112+
- master
142113
- test:
143114
context: reaction-validation
144115
requires:

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v1.7.0.3-meteor
2+
3+
- Update Meteor version to v1.7.0.3
4+
- Update node version to 8.11.3
5+
16
## v1.7.0.1-meteor
27

38
- Update Meteor version from v1.6.1 to v1.7.0.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
With the release of Meteor 1.7, we changed the versioning of this repo and it's Docker builds to align with Meteor's release. Henceforth, releases in this repo will be tied to the corresponding Meteor release.
66

7-
Current version builds:
7+
Sample version builds:
88

99
| reactioncommerce/base version | Meteor version |
1010
| :----------------------------------:|:---------------:|

Dockerfile renamed to versions/meteor-1.7.0.1/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM node:8.11.2
22

3+
ARG METEOR_VERSION
34
ARG NAME=base
45
ARG DESCRIPTION="Base Docker image for Reaction."
56
ARG URL=https://github.com/reactioncommerce/base
@@ -51,7 +52,7 @@ LABEL maintainer="Reaction Commerce <[email protected]>" \
5152
com.reactioncommerce.docker.git.sha1=$GIT_SHA1 \
5253
com.reactioncommerce.docker.license=$LICENSE
5354

54-
ENV METEOR_VERSION 1.7.0.1
55+
ENV METEOR_VERSION $METEOR_VERSION
5556
ENV REACTION_DOCKER_BUILD true
5657
ENV APP_SOURCE_DIR /opt/reaction/src
5758
ENV APP_BUNDLE_DIR /opt/reaction/dist

versions/meteor-1.7.0.1/options

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export TAGS=(v1.7.0.1-meteor)
2+
export METEOR_VERSION=1.7.0.1
File renamed without changes.

versions/meteor-1.7.0.3/Dockerfile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
FROM node:8.11.3
2+
3+
ARG METEOR_VERSION
4+
ARG NAME=base
5+
ARG DESCRIPTION="Base Docker image for Reaction."
6+
ARG URL=https://github.com/reactioncommerce/base
7+
ARG DOC_URL=https://github.com/reactioncommerce/base
8+
ARG VCS_URL=https://github.com/reactioncommerce/base
9+
ARG VCS_REF
10+
ARG VENDOR
11+
ARG BUILD_DATE
12+
ARG BUILD_COMPARE_URL
13+
ARG BUILD_ENV=test
14+
ARG BUILD_NUMBER
15+
ARG BUILD_PLATFORM
16+
ARG BUILD_PLATFORM_PROJECT_USERNAME
17+
ARG BUILD_PLATFORM_PROJECT_REPONAME
18+
ARG BUILD_PULL_REQUESTS
19+
ARG BUILD_TRIGGERED_BY_TAG
20+
ARG BUILD_URL
21+
ARG CIRCLE_WORKSPACE_ID
22+
ARG CIRCLE_WORKFLOW_ID
23+
ARG CIRCLE_WORKFLOW_JOB_ID
24+
ARG CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS
25+
ARG CIRCLE_WORKSPACE_ID
26+
ARG GIT_REPOSITORY_URL
27+
ARG GIT_SHA1
28+
ARG LICENSE
29+
30+
LABEL maintainer="Reaction Commerce <[email protected]>" \
31+
com.reactioncommerce.build-date=$BUILD_DATE \
32+
com.reactioncommerce.name=$NAME \
33+
com.reactioncommerce.description=$DESCRIPTION \
34+
com.reactioncommerce.url=$URL \
35+
com.reactioncommerce.vcs-url=$VCS_URL \
36+
com.reactioncommerce.vcs-ref=$VCS_REF \
37+
com.reactioncommerce.vendor=$VENDOR \
38+
com.reactioncommerce.docker.build.compare-url=$BUILD_COMPARE_URL \
39+
com.reactioncommerce.docker.build.number=$BUILD_NUMBER \
40+
com.reactioncommerce.docker.build.platform=$BUILD_PLATFORM \
41+
com.reactioncommerce.docker.build.platform.project.username=$BUILD_PLATFORM_PROJECT_USERNAME \
42+
com.reactioncommerce.docker.build.platform.project.reponame=$BUILD_PLATFORM_PROJECT_REPONAME \
43+
com.reactioncommerce.docker.build.pull-requests=$BUILD_PULL_REQUESTS \
44+
com.reactioncommerce.docker.build.triggered-by-tag=$BUILD_TRIGGERED_BY_TAG \
45+
com.reactioncommerce.docker.build.url=$BUILD_URL \
46+
com.reactioncommerce.docker.build.circle.workflow.id=$CIRCLE_WORKFLOW_ID \
47+
com.reactioncommerce.docker.build.circle.workflow.job.id=$CIRCLE_WORKFLOW_JOB_ID \
48+
com.reactioncommerce.docker.build.circle.workflow.upstream.job.ids=$CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS \
49+
com.reactioncommerce.docker.build.circle.workflow.url=https://circleci.com/workflow-run/$CIRCLE_WORKFLOW_ID \
50+
com.reactioncommerce.docker.build.circle.workspace.id=$CIRCLE_WORKSPACE_ID \
51+
com.reactioncommerce.docker.git.repository.url=$GIT_REPOSITORY_URL \
52+
com.reactioncommerce.docker.git.sha1=$GIT_SHA1 \
53+
com.reactioncommerce.docker.license=$LICENSE
54+
55+
ENV METEOR_VERSION $METEOR_VERSION
56+
ENV REACTION_DOCKER_BUILD true
57+
ENV APP_SOURCE_DIR /opt/reaction/src
58+
ENV APP_BUNDLE_DIR /opt/reaction/dist
59+
ENV PATH $PATH:/home/node/.meteor
60+
61+
RUN apt-get update \
62+
&& apt-get install -y --no-install-recommends \
63+
build-essential \
64+
bsdtar \
65+
bzip2 \
66+
ca-certificates \
67+
git \
68+
python \
69+
wget \
70+
&& rm -rf /var/lib/apt/lists/*
71+
72+
RUN mkdir -p "$APP_SOURCE_DIR" \
73+
&& mkdir -p "$APP_BUNDLE_DIR" \
74+
&& chown -R node "$APP_SOURCE_DIR" \
75+
&& chown -R node "$APP_BUNDLE_DIR"
76+
77+
RUN npm i -g reaction-cli
78+
79+
USER node
80+
81+
################################
82+
# install-meteor
83+
# replaces tar command with bsdtar in the install script (bsdtar -xf "$TARBALL_FILE" -C "$INSTALL_TMPDIR")
84+
# https://github.com/jshimko/meteor-launchpad/issues/39
85+
################################
86+
RUN wget -O /tmp/install_meteor.sh https://install.meteor.com \
87+
&& sed -i.bak "s/RELEASE=.*/RELEASE=\"$METEOR_VERSION\"/g" /tmp/install_meteor.sh \
88+
&& sed -i.bak "s/tar -xzf.*/bsdtar -xf \"\$TARBALL_FILE\" -C \"\$INSTALL_TMPDIR\"/g" /tmp/install_meteor.sh \
89+
&& printf "\\n[-] Installing Meteor %s...\\n" "$METEOR_VERSION" \
90+
&& sh /tmp/install_meteor.sh \
91+
&& rm /tmp/install_meteor.sh
92+
93+
WORKDIR $APP_SOURCE_DIR
94+
COPY test-script.sh .
95+
# Node flags for the Meteor build tool
96+
ONBUILD ARG TOOL_NODE_FLAGS
97+
ONBUILD ENV TOOL_NODE_FLAGS $TOOL_NODE_FLAGS

versions/meteor-1.7.0.3/options

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export TAGS=(v1.7.0.3-meteor latest)
2+
export METEOR_VERSION=1.7.0.3
3+

0 commit comments

Comments
 (0)