build(docker): build docker image and push to hub (#414)
* build(docker): build docker image and push to hub Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com> * build(docker): trigger only on new release Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
parent
cc658acd54
commit
ef2dd1949a
@ -1,4 +1,11 @@
|
||||
version: 2
|
||||
version: 2.1
|
||||
|
||||
executors:
|
||||
docker-publisher:
|
||||
environment:
|
||||
IMAGE_NAME: bukuserver/bukuserver
|
||||
docker:
|
||||
- image: circleci/buildpack-deps:stretch
|
||||
|
||||
test-template: &test-template
|
||||
working_directory: ~/Buku
|
||||
@ -53,8 +60,39 @@ jobs:
|
||||
go get github.com/tcnksm/ghr
|
||||
ghr -t ${GITHUB_API_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -replace ${CIRCLE_TAG} ./dist/
|
||||
|
||||
build-docker-image:
|
||||
executor: docker-publisher
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker
|
||||
- run:
|
||||
name: Build Docker image
|
||||
command: docker build -t $IMAGE_NAME:latest .
|
||||
- run:
|
||||
name: Archive Docker image
|
||||
command: docker save -o image.tar $IMAGE_NAME
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- ./image.tar
|
||||
|
||||
publish-on-docker-hub:
|
||||
executor: docker-publisher
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- setup_remote_docker
|
||||
- run:
|
||||
name: Load archived Docker image
|
||||
command: docker load -i /tmp/workspace/image.tar
|
||||
- run:
|
||||
name: Publish Docker Image to Docker Hub
|
||||
command: |
|
||||
echo "${DOCKERHUB_PASS}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
|
||||
docker push ${IMAGE_NAME}:latest
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
version: 2.1
|
||||
|
||||
test:
|
||||
jobs: &all-tests
|
||||
@ -80,3 +118,21 @@ workflows:
|
||||
only: /^v.*/
|
||||
branches:
|
||||
ignore: /.*/
|
||||
|
||||
publish-docker-image:
|
||||
jobs:
|
||||
- build-docker-image:
|
||||
filters:
|
||||
tags:
|
||||
only: /^v.*/
|
||||
branches:
|
||||
ignore: /.*/
|
||||
- publish-on-docker-hub:
|
||||
requires:
|
||||
- build-docker-image
|
||||
filters:
|
||||
tags:
|
||||
only: /^v.*/
|
||||
branches:
|
||||
ignore: /.*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user