Skip to content

Commit

Permalink
[INFRA-660] Dockerized cloudlift (GetSimpl#20)
Browse files Browse the repository at this point in the history
* add Dockerfile to run tests in a consistent manner

* fix service update test

* update docker config

* add Jenkinsfile

* update Jenkinsfile

* fix

* improved jenkins file

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix working dirs

* add git

* add docker client

* fix

* review comments

Co-authored-by: Bhavin Doshi <[email protected]>
  • Loading branch information
siliconsenthil and Bhavin Doshi authored Aug 27, 2020
1 parent edfd5a3 commit 76cc7ce
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git
.gitignore
venv
*.egg-info
dist
Dockerfile
build
.pytest_cache
**/__pycache__
**/*.pyc
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.7.7-slim
RUN apt-get update && apt-get install make git docker.io -y
WORKDIR /cloudlift-bin
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
RUN pip install -e .
WORKDIR /workspace
ENTRYPOINT ["cloudlift"]
43 changes: 43 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pipeline {
agent {
label 'dockerbuild'
}
options { disableConcurrentBuilds() }
stages {
stage("Tag Cloudlift") {
steps {
println params
sh '''
git remote set-url origin [email protected]:Rippling/cloudlift || git remote add origin [email protected]:Rippling/cloudlift
if ! [ -z "${COMMIT_ID}" ]; then
echo "Checking out custom commit id: ${COMMIT_ID}"
git checkout ${COMMIT_ID}
fi
git fetch --prune origin "+refs/tags/*:refs/tags/*"
echo "Tagging this commit: $(git rev-parse HEAD)"
git tag ${TAG}
git push origin refs/tags/${TAG}
echo "List of git tag:\n$(git tag -l)"
'''
}
}

stage("Build Docker Image") {
steps {
sh '''
docker build -t cloudlift:${TAG} .
'''
}
}

stage('Push to ECR') {
steps {
sh '''
aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_RIPPLING_ACCOUNT}
docker tag cloudlift:${TAG} ${AWS_RIPPLING_ACCOUNT}/cloudlift-repo:${TAG}
docker push ${AWS_RIPPLING_ACCOUNT}/cloudlift-repo:${TAG}
'''
}
}
}
}
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ clean:
test-template:
python3 -m pytest test/deployment/service_template_generator_test.py -vv

test-unit:
pytest -s test/deployment/*

test-integration:
pytest -s test/test_cloudlift.py

Expand All @@ -24,4 +27,5 @@ install-test-package:
package-upload: package
python3 -m twine upload dist/*


package-docker:
docker build -t cloudlift .
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ To run high level integration tests
pytest -s test/test_cloudlift.py
```

To run tests inside docker container

```sh
docker build -t cloudlift .
docker run -it cloudlift
```

This tests expects to have an access to AWS console.
Since there's no extensive test coverage, it's better to manually test the
impacted areas whenever there's a code change.

0 comments on commit 76cc7ce

Please sign in to comment.