Commit 30b87bbf authored by Andrew Newdigate's avatar Andrew Newdigate

Further cleanup

parent f00dc151
node_modules
output
.git
.settings
.idea
......
......@@ -15,39 +15,13 @@ stages:
# this means that this fork is not production ready quite yet
- npm shrinkwrap
.job_template: &docker_job
image: registry.gitlab.com/gitlab-org/gitter/webapp/dind:latest
services:
- docker:dind
# Disabled for now
# test:
# <<: *docker_job
# stage: build_unit_test
# variables:
# COMPOSE_HTTP_TIMEOUT: 120 # Two minute timeout for slow pulls
# script:
# - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
# - ./exec-in-docker2 make test
validate:
<<: *node_job
stage: build_unit_test
script:
- make validate
package:
<<: *node_job
stage: build_unit_test
script:
- make package
artifacts:
paths:
- output/app.tar.gz
- output/assets.tar.gz
expire_in: 1 week
testing:
test:
<<: *node_job
variables:
BLUEBIRD_DEBUG: 1
......@@ -59,33 +33,45 @@ testing:
script:
- make ci-test
docker-base:
variables:
DOCKER_DRIVER: overlay
stage: docker_images
only:
- schedules
image: docker:latest
services:
- docker:dind
package:
<<: *node_job
stage: build_unit_test
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/gitlab-org/gitter/webapp .
- docker push registry.gitlab.com/gitlab-org/gitter/webapp
- make package
- ls -la output/
artifacts:
paths:
- output/*,
- output/app/ASSET_TAG,
- output/app/GIT_COMMIT,
- output/app/VERSION
expire_in: 1 week
docker-dind:
containerize:
stage: deploy
variables:
DOCKER_DRIVER: overlay
stage: docker_images
only:
- schedules
image: docker:latest
dependencies:
- package
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/gitlab-org/gitter/webapp/dind:latest scripts/docker/dind/
- docker push registry.gitlab.com/gitlab-org/gitter/webapp/dind:latest
- docker build -t registry.gitlab.com/gitlab-org/gitter/webapp/app:$CI_COMMIT_REF_SLUG -f Dockerfile-app-base .
- docker push registry.gitlab.com/gitlab-org/gitter/webapp/app:$CI_COMMIT_REF_SLUG
# upload-staging:
# stage: deploy
# image: python:latest
# dependencies:
# - package
# script:
# - pip install awscli
# - aws s3 cp output/app s3://gitter-deployments/gitter-webapp/beta
# - aws s3 cp output/*
# only:
# - develop
deploy_beta:
stage: deploy
......@@ -107,6 +93,19 @@ deploy_beta_staging:
only:
- /^feature\/.*$/
docker-base:
variables:
DOCKER_DRIVER: overlay
stage: docker_images
only:
- schedules
image: docker:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/gitlab-org/gitter/webapp:latest .
- docker push registry.gitlab.com/gitlab-org/gitter/webapp:latest
mongo-base:
variables:
......
FROM registry.gitlab.com/gitlab-org/gitter/webapp:latest
WORKDIR /app
COPY output/app.tar.gz /tmp/app.tar.gz
RUN tar -xvzf /tmp/app.tar.gz -C /app && \
rm -rf node_modules npm-shrinkwrap.json package-lock.json && \
npm install --production
RUN rm -rf /tmp/* /npm_cache /var/cache/apk/* /root/.npm /root/.node-gyp /root/.gnupg /root/.ssh 2>/dev/null
#
# Redis
#
redis1:
image: redis:3.0.3
restart: always
entrypoint: [ "/usr/local/bin/redis-server", "--bind", "0.0.0.0", "--port", "6379", "--maxclients", "200", "--dir", "/tmp", "--save", ""]
redis2:
image: redis:3.0.3
restart: always
links:
- redis1
entrypoint: [ "/usr/local/bin/redis-server", "--bind", "0.0.0.0", "--port", "6380", "--slaveof", "redis1", "6379", "--maxclients", "200", "--dir", "/tmp", "--save", ""]
sentinel1:
image: redis:3.0.3
restart: 'on-failure:5'
links:
- redis1
- redis2
ports:
- 26379
entrypoint:
- /bin/bash
- -c
- |
echo 'sentinel monitor gitter-master-dev redis1 6379 1' > /redis-sentinel.conf &&
exec /usr/local/bin/redis-server /redis-sentinel.conf --sentinel --bind 0.0.0.0 --maxclients 200
#
# Mongo
#
mongo1:
image: mongo:3.2
restart: always
links:
- mongo2
- mongo3
entrypoint: [ "/usr/bin/mongod", "--replSet", "troupeSet", "--journal", "--smallfiles", "--storageEngine=wiredTiger", "--oplogSize=20", "--port=27017"]
mongo2:
image: mongo:3.2
restart: always
entrypoint: [ "/usr/bin/mongod", "--replSet", "troupeSet", "--journal", "--smallfiles", "--storageEngine=wiredTiger", "--oplogSize=20", "--port=27018"]
mongo3:
image: mongo:3.2
restart: always
entrypoint: [ "/usr/bin/mongod", "--replSet", "troupeSet", "--journal", "--smallfiles", "--storageEngine=wiredTiger", "--oplogSize=20", "--port=27019"]
mongosetup:
image: mongo:3.2
restart: 'no'
links:
- mongo1
- mongo2
- mongo3
volumes:
- ${WORKSPACE}:/src
environment:
ANNOUNCE_MONGO1_HOST: ""
ANNOUNCE_MONGO2_HOST: ""
ANNOUNCE_MONGO3_HOST: ""
working_dir: /src
entrypoint: [ "/src/scripts/docker/mongo/mongo-setup.sh" ]
neo4j:
image: neo4j:2.3.0
restart: always
environment:
NEO4J_AUTH: none
elasticsearch:
image: elasticsearch:1.4.2
links:
- mongo1
- mongo2
- mongo3
volumes:
- ${WORKSPACE}:/src
environment:
ANNOUNCE_ES_HOST:
working_dir: /src
entrypoint: [ "/src/scripts/docker/es/start-elasticsearch.sh", "fast"]
elasticsearchsetup:
image: elasticsearch:1.4.2
restart: 'no'
links:
- mongo1
- mongo2
- mongo3
- elasticsearch
volumes:
- ${WORKSPACE}:/src
working_dir: /src
entrypoint: [ "/src/scripts/docker/es/setup-elasticsearch.sh" ]
internal-min:
image: registry.gitlab.com/gitlab-org/gitter/webapp
restart: 'no'
links:
- redis1
- redis2
- mongo1
- mongo2
- mongo3
- sentinel1
- elasticsearch
- neo4j
environment:
NODE_ENV: ${NODE_ENV}
DEBUG: ${DEBUG}
volumes:
- ${WORKSPACE}:${WORKSPACE}
working_dir: ${WORKSPACE}
internal:
image: registry.gitlab.com/gitlab-org/gitter/webapp
restart: 'no'
links:
- redis1
- redis2
- neo4j
- mongo1
- mongo2
- mongo3
- elasticsearch
- sentinel1
volumes:
- ${WORKSPACE}:/src
working_dir: /src
#!/bin/bash -eu
set -u
set -e
set -x
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKSPACE="${WORKSPACE-$SCRIPT_DIR}"
DEBUG="${DEBUG:-}"
NODE_ENV="${NODE_ENV:-test-docker}"
NODE_VERSION="$(node --version)"
NODE_VERSION="${NODE_VERSION#v}" # Drop the `v` prefix
export WORKSPACE
export DEBUG
export NODE_VERSION
export NODE_ENV
SU_TO_UID=${UID}
SU_TO_USER=${USER}
export SU_TO_USER
export SU_TO_UID
case $OSTYPE in
darwin*)
TARGET_DOCKER_CONTAINER=internal-mac
mkdir -p "${SCRIPT_DIR}/node_modules_linux"
;;
*)
TARGET_DOCKER_CONTAINER=internal-min
;;
esac
function mongo_run {
docker-compose -p "${PROJECT_NAME}" -f docker-compose.internal.yml run --rm "${1}"
}
ISOLATED_UNIQ_ID=${BUILD_NUMBER:-$(date +"%Y%m%d%H%M%S")}
PROJECT_NAME="webapp${ISOLATED_UNIQ_ID}"
if [[ -z ${GITTER_SECRETS_ENV_FILE:-} ]]; then
GITTER_SECRETS_ENV_FILE=$(mktemp)
export GITTER_SECRETS_ENV_FILE
FAKE_GITTER_SECRETS_ENV_FILE=true
fi
function finish {
docker-compose -p "${PROJECT_NAME}" -f docker-compose.internal.yml stop
docker-compose -p "${PROJECT_NAME}" -f docker-compose.internal.yml rm -f -v
if [[ ${FAKE_GITTER_SECRETS_ENV_FILE:-} == "true" ]]; then
rm "${GITTER_SECRETS_ENV_FILE}"
fi
}
trap finish EXIT
function setup_env {
(mongo_run mongosetup ) &
(sleep 2; mongo_run elasticsearchsetup) &
echo "Waiting for setup to complete"
wait
echo "Setup complete"
}
if [[ -z "${SKIP_COMPOSE_SETUP:-}" ]]; then
setup_env
fi
docker-compose -p "${PROJECT_NAME}" -f docker-compose.internal.yml run \
-e "NODE_ENV=${NODE_ENV}" \
-e "DEBUG=${DEBUG}" \
-e "GIT_COMMIT=${GIT_COMMIT:-}" \
-e "GIT_BRANCH=${GIT_BRANCH:-}" \
-e "BUILD_NUMBER=${BUILD_NUMBER:-}" \
-e "BUILD_URL=${BUILD_URL:-}" \
-e "WORKSPACE=${WORKSPACE:-}" \
-e "ghprbPullId=${ghprbPullId:-}" \
-e "ghprbActualCommit=${ghprbActualCommit:-}" \
-e "ghprbSourceBranch=${ghprbSourceBranch:-}" \
"${TARGET_DOCKER_CONTAINER}" \
"${WORKSPACE}/scripts/docker/exec/exec.sh" "$@"
echo "docker-compose run exited with $?"
docker-compose -p "${PROJECT_NAME}" -f docker-compose.internal.yml ps
docker ps -a|grep "${PROJECT_NAME}"
echo "exec-in-docker complete, shutting down"
#!/bin/sh
set -u
set -e
set -x
WORKSPACE="$(pwd)"
DEBUG="${DEBUG:-}"
NODE_ENV="${NODE_ENV:-test-docker}"
NODE_VERSION="4"
export WORKSPACE
export DEBUG
export NODE_VERSION
export NODE_ENV
TARGET_DOCKER_CONTAINER=internal-min
function setup_env {
docker-compose -f docker-compose.internal.yml run --rm mongosetup &
sleep 2;
docker-compose -f docker-compose.internal.yml run --rm elasticsearchsetup &
echo "Waiting for setup to complete"
wait
echo "Setup complete"
}
if [[ -z "${SKIP_COMPOSE_SETUP:-}" ]]; then
setup_env
fi
docker-compose -f docker-compose.internal.yml run \
-e "NODE_ENV=${NODE_ENV}" \
-e "DEBUG=${DEBUG}" \
-e "WORKSPACE=${WORKSPACE:-}" \
"${TARGET_DOCKER_CONTAINER}" \
"/bin/sh" "-c" "$@"
echo "docker-compose run exited with $?"
# docker-compose -f docker-compose.internal.yml ps
# docker ps -a|grep "${PROJECT_NAME}"
echo "exec-in-docker complete, shutting down"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment