This repository has been archived by the owner on Aug 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from microscaling/labels
Labels
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
FROM alpine:3.3 | ||
FROM alpine:3.4 | ||
MAINTAINER Ross Fairbanks "[email protected]" | ||
|
||
COPY sleep.sh /sleep.sh | ||
COPY sleep.sh Dockerfile / | ||
|
||
# Metadata params | ||
ARG VERSION | ||
ARG VCS_URL | ||
ARG VCS_REF | ||
ARG BUILD_DATE | ||
|
||
# Metadata | ||
LABEL org.label-schema.vendor="Microscaling Systems" \ | ||
org.label-schema.license="MIT" \ | ||
org.label-schema.url="https://microscaling.com" \ | ||
org.label-schema.vcs-type="git" \ | ||
org.label-schema.vcs-url=$VCS_URL \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.dockerfile="/Dockerfile" | ||
|
||
ENTRYPOINT ["/sleep.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
default: build | ||
|
||
# Build Docker image | ||
build: docker_build output | ||
|
||
# Build and push Docker image | ||
release: docker_build docker_push output | ||
|
||
# Image and binary can be overidden with env vars. | ||
DOCKER_IMAGE ?= microscaling/microscaling-demo | ||
|
||
# Get the latest commit. | ||
GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD)) | ||
|
||
# Get the version number from the code | ||
CODE_VERSION = $(strip $(shell cat VERSION)) | ||
|
||
# Find out if the working directory is clean | ||
GIT_NOT_CLEAN_CHECK = $(shell git status --porcelain) | ||
ifneq (x$(GIT_NOT_CLEAN_CHECK), x) | ||
DOCKER_TAG_SUFFIX = "-dirty" | ||
endif | ||
|
||
# If we're releasing to Docker Hub, and we're going to mark it with the latest tag, it should exactly match a version release | ||
ifeq ($(MAKECMDGOALS),release) | ||
# Use the version number as the release tag. | ||
DOCKER_TAG = $(CODE_VERSION) | ||
|
||
ifndef CODE_VERSION | ||
$(error You need to create a VERSION file to build a release) | ||
endif | ||
|
||
# See what commit is tagged to match the version | ||
VERSION_COMMIT = $(strip $(shell git rev-list $(CODE_VERSION) -n 1 | cut -c1-7)) | ||
ifneq ($(VERSION_COMMIT), $(GIT_COMMIT)) | ||
$(error echo You are trying to push a build based on commit $(GIT_COMMIT) but the tagged release version is $(VERSION_COMMIT)) | ||
endif | ||
|
||
# Don't push to Docker Hub if this isn't a clean repo | ||
ifneq (x$(GIT_NOT_CLEAN_CHECK), x) | ||
$(error echo You are trying to release a build based on a dirty repo) | ||
endif | ||
|
||
else | ||
# Add the commit ref for development builds. Mark as dirty if the working directory isn't clean | ||
DOCKER_TAG = $(CODE_VERSION)-$(GIT_COMMIT)$(DOCKER_TAG_SUFFIX) | ||
endif | ||
|
||
docker_build: $(BINARY) | ||
# Build Docker image | ||
docker build \ | ||
--build-arg VCS_URL=`git config --get remote.origin.url` \ | ||
--build-arg VCS_REF=$(GIT_COMMIT) \ | ||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ | ||
-t $(DOCKER_IMAGE):$(DOCKER_TAG) . | ||
|
||
docker_push: | ||
# Tag image as latest | ||
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest | ||
|
||
# Push to DockerHub | ||
docker push $(DOCKER_IMAGE):$(DOCKER_TAG) | ||
docker push $(DOCKER_IMAGE):latest | ||
|
||
output: | ||
@echo Docker Image: $(DOCKER_IMAGE):$(DOCKER_TAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v1.4.0 |