Skip to content

Commit ae6abfd

Browse files
committed
fix: docker build versioning
1 parent 516c756 commit ae6abfd

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

Dockerfile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ RUN wget -q https://use.fontawesome.com/releases/v5.0.6/fontawesome-free-5.0.6.z
2525

2626
RUN git clone --branch v1.5.0 --depth 1 https://github.com/ajaxorg/ace-builds.git
2727

28-
COPY .git .git/
29-
RUN if [ -d ".git" ]; then \
30-
CI_COMMIT_TAG=$(git describe --tags); \
31-
CI_COMMIT_REF_NAME=$(git rev-parse --abbrev-ref HEAD); \
32-
CI_COMMIT_SHA=$(git rev-parse --verify HEAD); \
33-
CI_COMMIT_SHORT_SHA=$(git rev-parse --verify HEAD | head -c 8); \
34-
fi; \
35-
echo "<?php return ['tag' => '$CI_COMMIT_TAG', 'sha' => '$CI_COMMIT_SHA', 'short_sha' => '$CI_COMMIT_SHORT_SHA','ref_name'=>'$CI_COMMIT_REF_NAME'];" > version.php
28+
RUN echo "<?php return ['tag' => '$CI_COMMIT_TAG', 'sha' => '$CI_COMMIT_SHA', 'short_sha' => '$CI_COMMIT_SHORT_SHA','ref_name'=>'$CI_COMMIT_REF_NAME'];" > version.php
3629

3730
COPY php php/
3831
COPY composer.json composer.lock ./

build.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# This script is for local builds.
4+
# It gathers version information from the local .git repository
5+
# and passes it as build arguments to the docker build command.
6+
7+
set -e
8+
9+
CI_COMMIT_TAG=$(git describe --tags --always)
10+
CI_COMMIT_REF_NAME=$(git rev-parse --abbrev-ref HEAD)
11+
CI_COMMIT_SHA=$(git rev-parse --verify HEAD)
12+
CI_COMMIT_SHORT_SHA=$(git rev-parse --verify --short HEAD)
13+
14+
docker build .
15+
--build-arg CI_COMMIT_TAG="$CI_COMMIT_TAG" \
16+
--build-arg CI_COMMIT_REF_NAME="$CI_COMMIT_REF_NAME" \
17+
--build-arg CI_COMMIT_SHA="$CI_COMMIT_SHA" \
18+
--build-arg CI_COMMIT_SHORT_SHA="$CI_COMMIT_SHORT_SHA" \
19+
"$@"

0 commit comments

Comments
 (0)