|
|
|
@ -7,6 +7,11 @@ globals: |
|
|
|
postgres: &postgres circleci/postgres:9.6.5 |
|
|
|
caches: |
|
|
|
dependencies: &dependencies dependencies-{{ checksum "package.json" }} |
|
|
|
docker_hub: |
|
|
|
user-id: &dockerhub-user-id anthonyjhoiro |
|
|
|
password: &dockerhub-password $DOCKERHUB_PASSWORD |
|
|
|
image: &dockerhub-image devops-tpfinal |
|
|
|
|
|
|
|
|
|
|
|
# --- Commands --- # |
|
|
|
|
|
|
|
@ -72,6 +77,27 @@ jobs: |
|
|
|
name: Lint files |
|
|
|
command: yarn lint |
|
|
|
|
|
|
|
docker-build: |
|
|
|
<<: *shared-config |
|
|
|
environment: |
|
|
|
DOCKER_HUB_PWD: *dockerhub-password |
|
|
|
DOCKER_HUB_USER_ID: *dockerhub-user-id |
|
|
|
DOCKER_HUB_IMAGE: *dockerhub-image |
|
|
|
steps: |
|
|
|
- checkout |
|
|
|
- setup_remote_docker |
|
|
|
- run: |
|
|
|
name: Build docker image |
|
|
|
command: docker build --cache-from=app -t app . |
|
|
|
- deploy: |
|
|
|
name: Publish image to Docker Hub |
|
|
|
command: | |
|
|
|
echo $DOCKER_HUB_PWD | docker login -u $DOCKER_HUB_USER_ID --password-stdin |
|
|
|
docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:$CIRCLE_BUILD_NUM |
|
|
|
docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:latest |
|
|
|
docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:$CIRCLE_BUILD_NUM |
|
|
|
docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:latest |
|
|
|
|
|
|
|
# --- Workflow definition --- # |
|
|
|
|
|
|
|
workflows: |
|
|
|
@ -88,3 +114,13 @@ workflows: |
|
|
|
- lint: |
|
|
|
requires: |
|
|
|
- build |
|
|
|
- docker-build: |
|
|
|
requires: |
|
|
|
- test |
|
|
|
- test:e2e |
|
|
|
- lint |
|
|
|
# Add it before pull request |
|
|
|
# filters: |
|
|
|
# branches: |
|
|
|
# only: |
|
|
|
# - main |