mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 02:53:51 +00:00
Add build-time args
This commit is contained in:
@@ -8,5 +8,6 @@ services:
|
||||
context: ./dns
|
||||
dockerfile: Dockerfile.dev
|
||||
args:
|
||||
- BUILD_DATE=${BUILD_DATE}
|
||||
- GIT_COMMIT=${GIT_COMMIT}
|
||||
- DNS_VERSION
|
||||
- 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
|
||||
ARG ALPINE_VERSION=3.18
|
||||
ARG GO_VERSION=1.21.3
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# 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"
|
||||
|
||||
[containers]
|
||||
|
||||
[packages]
|
||||
dns = "0.0.0"
|
||||
proxy = "0.0.0"
|
||||
|
||||
30
web
30
web
@@ -4,10 +4,23 @@
|
||||
action="$1"
|
||||
environment="$2"
|
||||
|
||||
# Set the build arguments as environment variables
|
||||
export BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
export GIT_COMMIT=$(git rev-parse --short HEAD)
|
||||
# Pulls project version from version.toml
|
||||
project_version() {
|
||||
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
|
||||
help)
|
||||
@@ -21,8 +34,8 @@ case $action in
|
||||
echo ""
|
||||
echo "Actions:"
|
||||
echo " * build"
|
||||
echo " - builds either the entire stack without cache or select container"
|
||||
echo " - example: '{action} {environment}' or '{action} {container} {environment}'"
|
||||
echo " - builds the entire stack without cache"
|
||||
echo " - example: '{action} {environment}' or '{action} {environment}"
|
||||
echo ""
|
||||
echo " * run"
|
||||
echo " - runs the entire stack with caching enabled"
|
||||
@@ -43,7 +56,12 @@ case $action in
|
||||
build)
|
||||
if [ "$environment" == "dev" ];
|
||||
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" ];
|
||||
then
|
||||
|
||||
Reference in New Issue
Block a user