Browse Source

👷 Add docker push config

pull/2/head
anthony 5 years ago
parent
commit
f79b570120
  1. 36
      .circleci/config.yml

36
.circleci/config.yml

@ -7,6 +7,11 @@ globals:
postgres: &postgres circleci/postgres:9.6.5 postgres: &postgres circleci/postgres:9.6.5
caches: caches:
dependencies: &dependencies dependencies-{{ checksum "package.json" }} 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 --- # # --- Commands --- #
@ -72,6 +77,27 @@ jobs:
name: Lint files name: Lint files
command: yarn lint 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 --- # # --- Workflow definition --- #
workflows: workflows:
@ -88,3 +114,13 @@ workflows:
- lint: - lint:
requires: requires:
- build - build
- docker-build:
requires:
- test
- test:e2e
- lint
# Add it before pull request
# filters:
# branches:
# only:
# - main
Loading…
Cancel
Save