-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
27 lines (20 loc) · 1.56 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
#!/bin/bash
echo "------ FRONTEND: BUILD HOOK WAS TRIGGERED -------"
printenv
# Caution: A hooks/build file overrides the basic docker build command used by the builder, so you must include a similar build command in the hook or the automated build fails.
# https://docs.docker.com/docker-hub/builds/advanced/
# ENV VARs are set by the cloud.docker.com build process, and are available during automated builds, automated tests, and while executing hooks like here.
# DOCKER_TAG: the Docker repository tag being built.
docker build -t $IMAGE_NAME -f $DOCKERFILE_PATH --build-arg SERVER_HOST_ARG=$SERVER_HOST_FROM_DOCKER_HUB --build-arg SERVER_PORT_ARG=$SERVER_PORT_FROM_DOCKER_HUB .
echo "------ FRONTEND: BUILD HOOK WAS STOPPED -------"
# See this post for the detailed explanation:
# https://stackoverflow.com/questions/45277186/is-it-possible-to-add-environment-variables-in-automated-builds-in-docker-hub
# Build hook examples' source code: https://github.com/binbashar/public-docker-images/tree/master/terraform-resources
# Default environment variables used in Docker Hub:
# SOURCE_BRANCH: the name of the branch or the tag that is currently being tested.
# SOURCE_COMMIT: the SHA1 hash of the commit being tested.
# COMMIT_MSG: the message from the commit being tested and built.
# DOCKER_REPO: the name of the Docker repository being built.
# DOCKERFILE_PATH: the dockerfile currently being built.
# DOCKER_TAG: the Docker repository tag being built.
# IMAGE_NAME: the name and tag of the Docker repository being built. (This variable is a combination of DOCKER_REPO:DOCKER_TAG.)