Skip to content

Commit 523705c

Browse files
committed
Use Docker orb for publishing new image to DockerHub
1 parent 28ace32 commit 523705c

1 file changed

Lines changed: 14 additions & 24 deletions

File tree

.circleci/config.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: 2.1
33
orbs:
44
aws-ecr: circleci/aws-ecr@4.0.1
55
aws-ecs: circleci/aws-ecs@0.0.8
6+
docker: circleci/docker@0.5.1
67

78

89
workflows:
@@ -11,13 +12,24 @@ workflows:
1112
- build_test
1213

1314
# push new Docker image to Docker Hub
14-
- dockerhub_build_and_push:
15+
- docker/publish:
16+
image: operationcode/pybot
17+
dockerfile: docker/Dockerfile
18+
tag: ${CIRCLE_BRANCH}
19+
after_build:
20+
- run:
21+
name: Tag and Push
22+
command: |
23+
IMAGE_ID=operationcode/pybot
24+
docker tag ${IMAGE_ID}:${CIRCLE_BRANCH} ${IMAGE_ID}:${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}
25+
docker push ${IMAGE_ID}:${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}
1526
requires:
1627
- build_test
1728
filters:
1829
branches:
1930
only:
2031
- master
32+
- staging
2133

2234

2335
# push new Docker image to ECS
@@ -87,26 +99,4 @@ jobs:
8799
poetry run pytest --junitxml=test-results/pytest/results.xml
88100
89101
- store_test_results:
90-
path: test-results
91-
92-
dockerhub_build_and_push:
93-
docker:
94-
- image: circleci/python:3.7.1
95-
96-
steps:
97-
- checkout
98-
99-
- setup_remote_docker:
100-
docker_layer_caching: true
101-
102-
- run:
103-
name: Build and push to DockerHub
104-
command: |
105-
echo ${DOCKER_HUB_PASSWORD} | docker login -u ${DOCKER_HUB_USERNAME} --password-stdin
106-
107-
docker build -f docker/Dockerfile \
108-
-t operationcode/pybot:${CIRCLE_BUILD_NUM} \
109-
-t operationcode/pybot:latest .
110-
111-
docker push operationcode/pybot:latest
112-
docker push operationcode/pybot:${CIRCLE_BUILD_NUM}
102+
path: test-results

0 commit comments

Comments
 (0)