forked from pymedusa/Medusa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·41 lines (32 loc) · 1.16 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# This is a Docker Hub build hook.
# It is used to inject the current commit hash and branch name as build-args.
# See https://docs.docker.com/docker-hub/builds/advanced/
echo "Executing hooks/build"
echo "IMAGE_NAME: $IMAGE_NAME"
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "BUILD_DATE: $BUILD_DATE"
# Make sure these are available, and complete them using git if not
# Git Branch
echo "SOURCE_BRANCH: $SOURCE_BRANCH"
if [[ -z "$SOURCE_BRANCH" ]]; then
echo "Updating SOURCE_BRANCH from git rev-parse --abbrev-ref HEAD"
export SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "SOURCE_BRANCH: $SOURCE_BRANCH"
fi
# Git Commit
# https://github.com/docker/hub-feedback/issues/600
echo "SOURCE_COMMIT: $SOURCE_COMMIT"
if [[ -z "$SOURCE_COMMIT" ]]; then
echo "Updating SOURCE_COMMIT from git rev-parse HEAD"
export SOURCE_COMMIT=$(git rev-parse HEAD)
echo "SOURCE_COMMIT: $SOURCE_COMMIT"
fi
echo "Running docker build"
docker build \
--build-arg "GIT_BRANCH=$SOURCE_BRANCH" \
--build-arg "GIT_COMMIT=$SOURCE_COMMIT" \
--build-arg "BUILD_DATE=$BUILD_DATE" \
--file "$DOCKERFILE_PATH" \
--tag "$IMAGE_NAME" \
.