67 lines
2.6 KiB
YAML
67 lines
2.6 KiB
YAML
# Template docker-push
|
|
|
|
# This template allows you to build and push your docker image to a Docker Hub account.
|
|
# The workflow allows running tests, code linting and security scans on feature branches (as well as master).
|
|
# The docker image will be validated and pushed to the docker registry after the code is merged to master.
|
|
|
|
# Prerequisites: $DOCKERHUB_USERNAME, $DOCKERHUB_PASSWORD setup as deployment variables
|
|
|
|
image: atlassian/default-image:2
|
|
|
|
|
|
definitions:
|
|
services:
|
|
docker:
|
|
memory: 3072
|
|
pipelines:
|
|
default:
|
|
- parallel:
|
|
- step:
|
|
name: Build images
|
|
script:
|
|
- docker build . --file docker/coturn/Dockerfile --tag coturn
|
|
- docker build . --file docker/coturn-dns/Dockerfile --tag coturn-dns
|
|
services:
|
|
- docker
|
|
caches:
|
|
- docker
|
|
- step:
|
|
name: Lint the Dockerfile
|
|
image: hadolint/hadolint:latest-debian
|
|
script:
|
|
- hadolint docker/coturn/Dockerfile
|
|
- hadolint docker/coturn-dns/Dockerfile
|
|
branches:
|
|
main:
|
|
- step:
|
|
name: Build images
|
|
script:
|
|
- docker build . --file docker/coturn/Dockerfile --tag coturn
|
|
- docker build . --file docker/coturn-dns/Dockerfile --tag coturn-dns
|
|
- docker save coturn --output "coturn.tar"
|
|
- docker save coturn-dns --output "coturn-dns.tar"
|
|
services:
|
|
- docker
|
|
caches:
|
|
- docker
|
|
artifacts:
|
|
- "*.tar"
|
|
- step:
|
|
name: Push images
|
|
image: google/cloud-sdk:alpine
|
|
script:
|
|
# Authenticating with the service account key file
|
|
- echo $GCLOUD_API_KEYFILE | base64 -d > ./gcloud-api-key.json
|
|
- gcloud auth activate-service-account --key-file gcloud-api-key.json
|
|
- gcloud config set project $GCLOUD_PROJECT
|
|
- docker load --input "coturn.tar"
|
|
- docker load --input "coturn-dns.tar"
|
|
- VERSION="latest" #VERSION="prod-0.1.${BITBUCKET_BUILD_NUMBER}"
|
|
- docker tag "coturn" "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION}"
|
|
- docker tag "coturn-dns" "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
|
|
# Login to google docker hub
|
|
- cat ./gcloud-api-key.json | docker login -u _json_key --password-stdin https://gcr.io
|
|
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION}"
|
|
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
|
|
services:
|
|
- docker |