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

Add new step to build Docker image from PRs for production again #15124

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Changes from all commits
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
107 changes: 98 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,87 @@ jobs:
exit 0
fi;

pr-build:
<<: *defaults
docker:
- image: circleci/node:8.11-stretch

steps:
- checkout

- restore_cache:
keys:
- node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}

- restore_cache:
keys:
- meteor-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/release" }}

- run:
name: Install Meteor
command: |
# Restore bin from cache
set +e
METEOR_SYMLINK_TARGET=$(readlink ~/.meteor/meteor)
METEOR_TOOL_DIRECTORY=$(dirname "$METEOR_SYMLINK_TARGET")
set -e
LAUNCHER=$HOME/.meteor/$METEOR_TOOL_DIRECTORY/scripts/admin/launch-meteor
if [ -e $LAUNCHER ]
then
echo "Cached Meteor bin found, restoring it"
sudo cp "$LAUNCHER" "/usr/local/bin/meteor"
else
echo "No cached Meteor bin found."
fi

# only install meteor if bin isn't found
command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh

- run:
name: Versions
command: |
npm --versions
node -v
meteor --version
meteor npm --versions
meteor node -v
git version

- run:
name: Meteor npm install
command: |
# rm -rf node_modules
# rm -f package-lock.json
meteor npm install

- restore_cache:
keys:
- meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/versions" }}

- restore_cache:
keys:
- livechat-meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/.app/.meteor/versions" }}

- restore_cache:
keys:
- livechat-node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/.app/package.json" }}

- run:
name: Build Rocket.Chat
environment:
TOOL_NODE_FLAGS: --max_old_space_size=3072
command: |
meteor build --server-only /tmp/build-pr


- persist_to_workspace:
root: /tmp/
paths:
- build-pr

- store_artifacts:
path: /tmp/build-pr

pr-image-build:
<<: *defaults

Expand All @@ -364,9 +445,9 @@ jobs:
exit 0
fi;

cd /tmp/build
tar xzf Rocket.Chat.tar.gz
rm Rocket.Chat.tar.gz
cd /tmp/build-pr
tar xzf repo.tar.gz
rm repo.tar.gz

docker login -u $DOCKER_USER -p $DOCKER_PASS

Expand All @@ -375,11 +456,11 @@ jobs:
docker build -t rocketchat/rocket.chat:pr-$CIRCLE_PR_NUMBER .
docker push rocketchat/rocket.chat:pr-$CIRCLE_PR_NUMBER

echo "Build preview Docker image"
cp ~/repo/.docker-mongo/Dockerfile .
cp ~/repo/.docker-mongo/entrypoint.sh .
docker build -t rocketchat/rocket.chat.preview:pr-$CIRCLE_PR_NUMBER .
docker push rocketchat/rocket.chat.preview:pr-$CIRCLE_PR_NUMBER
#echo "Build preview Docker image"
#cp ~/repo/.docker-mongo/Dockerfile .
#cp ~/repo/.docker-mongo/entrypoint.sh .
#docker build -t rocketchat/rocket.chat.preview:pr-$CIRCLE_PR_NUMBER .
#docker push rocketchat/rocket.chat.preview:pr-$CIRCLE_PR_NUMBER

workflows:
version: 2
Expand Down Expand Up @@ -433,12 +514,20 @@ workflows:
ignore: develop
tags:
only: /^[0-9]+\.[0-9]+\.[0-9]+(?:-(?:rc|beta)\.[0-9]+)?$/
- pr-image-build:
- pr-build:
requires:
- hold
filters:
branches:
ignore: develop
tags:
only: /^[0-9]+\.[0-9]+\.[0-9]+(?:-(?:rc|beta)\.[0-9]+)?$/
- pr-image-build:
requires:
- pr-build
filters:
branches:
ignore: develop
tags:
only: /^[0-9]+\.[0-9]+\.[0-9]+(?:-(?:rc|beta)\.[0-9]+)?$/