Skip to content

Instantly share code, notes, and snippets.

@fujimaki-k
Created September 5, 2020 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujimaki-k/9c51a25fd4fbf796fd00d2e4c5facb12 to your computer and use it in GitHub Desktop.
Save fujimaki-k/9c51a25fd4fbf796fd00d2e4c5facb12 to your computer and use it in GitHub Desktop.
CircleCI config.yml sample
version: 2.1
commands:
buildimage:
description: "Build docker image"
steps:
- checkout
- setup_remote_docker
- run:
name: "Install git command"
command: "apk add git"
- run:
name: "Build docker image"
command: |
FILES=$(git log --max-count 1 --name-only --oneline | awk 'NR>1 {print}' | grep Dockerfile)
for FILE in $FILES
do
IMAGE=$(dirname "$FILE")
docker build --force-rm --no-cache --pull --rm --squash --tag $IMAGE $IMAGE
done
- run:
name: "Push docker image to registry"
command: |
FILES=$(git log --max-count 1 --name-only --oneline | awk 'NR>1 {print}' | grep Dockerfile)
for FILE in $FILES
do
IMAGE=$(dirname "$FILE")
docker push $IMAGE
done
executors:
default:
docker:
- image: docker:stable
jobs:
build:
executor: default
steps:
- buildimage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment