mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 11:03:50 +00:00
Add build-time args
This commit is contained in:
@@ -8,5 +8,6 @@ services:
|
|||||||
context: ./dns
|
context: ./dns
|
||||||
dockerfile: Dockerfile.dev
|
dockerfile: Dockerfile.dev
|
||||||
args:
|
args:
|
||||||
- BUILD_DATE=${BUILD_DATE}
|
- DNS_VERSION
|
||||||
- GIT_COMMIT=${GIT_COMMIT}
|
- BUILD_DATE
|
||||||
|
- GIT_COMMIT
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
# Imported args
|
||||||
|
ARG BUILD_DATE
|
||||||
|
ARG GIT_COMMIT
|
||||||
|
ARG DNS_VERSION
|
||||||
|
|
||||||
|
# Print the values of the build arguments
|
||||||
|
RUN echo "DNS_VERSION=$DNS_VERSION"
|
||||||
|
|
||||||
# CoreDNS base image
|
# CoreDNS base image
|
||||||
ARG ALPINE_VERSION=3.18
|
ARG ALPINE_VERSION=3.18
|
||||||
ARG GO_VERSION=1.21.3
|
ARG GO_VERSION=1.21.3
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# The following version number is incremented whenever
|
# The following version number is incremented whenever
|
||||||
#a local package or service in this repository recieves a version bump!
|
# a container in this repository recieves a version bump!
|
||||||
|
|
||||||
[global]
|
[project]
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
|
||||||
[containers]
|
[containers]
|
||||||
|
dns = "0.0.0"
|
||||||
[packages]
|
proxy = "0.0.0"
|
||||||
|
|||||||
30
web
30
web
@@ -4,10 +4,23 @@
|
|||||||
action="$1"
|
action="$1"
|
||||||
environment="$2"
|
environment="$2"
|
||||||
|
|
||||||
# Set the build arguments as environment variables
|
# Pulls project version from version.toml
|
||||||
export BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
project_version() {
|
||||||
export GIT_COMMIT=$(git rev-parse --short HEAD)
|
local version=$(awk -F'[" ]+' '/^\[project\]/{getline; print $3}' "version.toml")
|
||||||
|
echo "v$version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pulls container version from version.toml
|
||||||
|
container_version() {
|
||||||
|
local container="$1"
|
||||||
|
local version=$(awk -F'[" ]+' -v container="$container" '/^\[containers\]/{block=$1} block == "[containers]" && $1 == container {getline; print $3}' "version.toml")
|
||||||
|
echo "v$version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set the build arguments as environment variables
|
||||||
|
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
GIT_COMMIT=$(git rev-parse --short HEAD)
|
||||||
|
PROJECT_VERSION=$(project_version)
|
||||||
|
|
||||||
case $action in
|
case $action in
|
||||||
help)
|
help)
|
||||||
@@ -21,8 +34,8 @@ case $action in
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Actions:"
|
echo "Actions:"
|
||||||
echo " * build"
|
echo " * build"
|
||||||
echo " - builds either the entire stack without cache or select container"
|
echo " - builds the entire stack without cache"
|
||||||
echo " - example: '{action} {environment}' or '{action} {container} {environment}'"
|
echo " - example: '{action} {environment}' or '{action} {environment}"
|
||||||
echo ""
|
echo ""
|
||||||
echo " * run"
|
echo " * run"
|
||||||
echo " - runs the entire stack with caching enabled"
|
echo " - runs the entire stack with caching enabled"
|
||||||
@@ -43,7 +56,12 @@ case $action in
|
|||||||
build)
|
build)
|
||||||
if [ "$environment" == "dev" ];
|
if [ "$environment" == "dev" ];
|
||||||
then
|
then
|
||||||
echo "build dev"
|
docker compose --file compose.dev.yml build \
|
||||||
|
--build-arg BUILD_DATE=$BUILD_DATE \
|
||||||
|
--build-arg GIT_COMMIT=$GIT_COMMIT \
|
||||||
|
--build-arg PROJECT_VERSION="$PROJECT_VERSION" \
|
||||||
|
--build-arg DNS_VERSION=$(container_version "dns") \
|
||||||
|
--build-arg PROXY_VERSION=$(container_version "proxy") \
|
||||||
|
|
||||||
elif [ "$environment" == "prod" ];
|
elif [ "$environment" == "prod" ];
|
||||||
then
|
then
|
||||||
|
|||||||
Reference in New Issue
Block a user