Skip to content

Commit c299418

Browse files
committed
chore: align source to GOPATH in build environment
This makes module path still work for Go version that does not support module.
1 parent b4bee2d commit c299418

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*
22
!.git
3+
!go.mod
34
!src/
45
!build/
56
!conf/docker-image

build/build-all-by-docker.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ cd $(dirname "$0")
66
source ./build-all.inc.sh
77

88
prefix=$(realpath ../)
9+
ghfs=/go/src/mjpclab.dev/ghfs
10+
911
rm -rf "$prefix/output/"
1012

1113
buildByDocker() {
@@ -15,16 +17,16 @@ buildByDocker() {
1517

1618
docker run \
1719
--rm \
18-
-v "$prefix":/mnt \
20+
-v "$prefix":"$ghfs" \
1921
-e EX_UID="$(id -u)" \
2022
-e EX_GID="$(id -g)" \
2123
golang:"$gover" \
2224
/bin/bash -c '
2325
sed -i -e "s;://[^/ ]*;://mirrors.aliyun.com;" /etc/apt/sources.list;
2426
apt-get update;
2527
apt-get install -yq git zip;
26-
/bin/bash /mnt/build/build.sh "$@";
27-
chown -R $EX_UID:$EX_GID /mnt/output;
28+
/bin/bash '"$ghfs"'/build/build.sh "$@";
29+
chown -R $EX_UID:$EX_GID '"$ghfs"'/output;
2830
' \
2931
'argv_0_placeholder' \
3032
"$@"

build/build-docker-image-dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
FROM golang AS builder
2-
COPY .git/ /mnt/ghfs/.git/
3-
COPY src/ /mnt/ghfs/src/
4-
COPY build/ /mnt/ghfs/build/
5-
RUN ["/bin/bash", "-c", "cd /mnt/ghfs/build/; source ./build.inc.sh; go build -ldflags \"$(getLdFlags)\" -o /tmp/ghfs /mnt/ghfs/src/main.go"]
2+
COPY .git/ /go/src/mjpclab.dev/ghfs/.git/
3+
COPY go.mod /go/src/mjpclab.dev/ghfs/go.mod
4+
COPY src/ /go/src/mjpclab.dev/ghfs/src/
5+
COPY build/ /go/src/mjpclab.dev/ghfs/build/
6+
RUN ["/bin/bash", "-c", "cd /go/src/mjpclab.dev/ghfs/build/; source ./build.inc.sh; go build -ldflags \"$(getLdFlags)\" -o /tmp/ghfs /go/src/mjpclab.dev/ghfs/src/main.go"]
67
RUN mkdir -p /output/usr/local/bin/; cp /tmp/ghfs /output/usr/local/bin/;
78
COPY conf/docker-image/ /output/
89

0 commit comments

Comments
 (0)