Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
0eed330e
Commit
0eed330e
authored
8 years ago
by
Lars Gierth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docker: simplify git ref resolution, thanks @chriscool
License: MIT Signed-off-by:
Lars Gierth
<
larsg@systemli.org
>
parent
518f7e06
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
8 deletions
+4
-8
.dockerignore
.dockerignore
+1
-0
Dockerfile
Dockerfile
+1
-5
test/Dockerfile
test/Dockerfile
+1
-2
test/sharness/t0300-docker-image.sh
test/sharness/t0300-docker-image.sh
+1
-1
No files found.
.dockerignore
View file @
0eed330e
.git/
!.git/HEAD
!.git/refs/
!.git/packed-refs
cmd/ipfs/ipfs
vendor/gx/
test/
This diff is collapsed.
Click to expand it.
Dockerfile
View file @
0eed330e
...
...
@@ -50,11 +50,7 @@ RUN apk add --update musl go=$GO_VERSION git bash wget ca-certificates \
# Invoke gx
&& cd $SRC_PATH \
&& gx --verbose install --global \
# We get the current commit using this hack,
# so that we don't have to copy all of .git/ into the build context.
# This saves us quite a bit of image size.
&& ref=$(cat .git/HEAD | grep ref | cut -d' ' -f2) \
&& commit=$(if [ -z "$ref" ]; then cat .git/HEAD; else cat ".git/$ref"; fi | head -c 7) \
&& mkdir .git/objects && commit=$(git rev-parse --short HEAD) \
&& echo "ldflags=-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$commit" \
# Build and install IPFS and entrypoint script
&& cd $SRC_PATH/cmd/ipfs \
...
...
This diff is collapsed.
Click to expand it.
test/Dockerfile
View file @
0eed330e
...
...
@@ -44,8 +44,7 @@ RUN apk add --update musl go=$GO_VERSION git bash wget ca-certificates \
COPY
. $SRC_PATH
RUN
cd
$SRC_PATH
\
&&
ref
=
$(
cat
.git/HEAD |
grep
ref |
cut
-d
' '
-f2
)
\
&&
commit
=
$(
if
[
-z
"
$ref
"
]
;
then
cat
.git/HEAD
;
else
cat
".git/
$ref
"
;
fi
|
head
-c
7
)
\
&&
mkdir
.git/objects
&&
commit
=
$(
git rev-parse
--short
HEAD
)
\
&&
echo
"ldflags=-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=
$commit
"
\
&&
cd
$SRC_PATH
/cmd/ipfs
\
&&
go build
-ldflags
"-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=
$commit
"
\
...
...
This diff is collapsed.
Click to expand it.
test/sharness/t0300-docker-image.sh
View file @
0eed330e
...
...
@@ -70,7 +70,7 @@ test_expect_success "version CurrentCommit is set" '
docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \
-q -O - http://localhost:8080/version" | grep Commit | cut -d" " -f2 >actual &&
docker_exec "$DOC_ID" "ipfs version --commit" | cut -d- -f2 >expected &&
[ "$(cat
expected
| wc -c)" -gt "1" ]
&& # check there actually is a commit set
test -s
expected && # check there actually is a commit set
test_cmp expected actual
'
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment