Skip to content

Commit 90f1960

Browse files
committed
We should avoid setting GO env variables
It should be enough to temporarily set GOPATH during docker image build to install tools in a shared directory and then add that directory to $PATH. The defaults on linux are: GOPATH = ~/go GOROOT = /usr/local/go GOMODCACHE = GOPATH[0]/pkg/mod
1 parent 1ab3d9e commit 90f1960

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ COPY --from=android /opt/android-sdk /opt/android-sdk
2323
ADD scripts/docker_install.sh /tmp/
2424
RUN /tmp/docker_install.sh
2525

26-
ENV GOPATH /opt/go
27-
ENV GOROOT /opt/go_dist/go
28-
ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
26+
# In this path executables will be installed during docker build
27+
ARG SYS_GOPATH /opt/go
28+
ENV PATH $SYS_GOPATH/bin:/usr/local/go/bin:$PATH
2929

3030
ADD Makefile /tmp/
31-
RUN make -C /tmp/ envinit
31+
RUN GOPATH=$SYS_GOPATH make -C /tmp/ envinit
3232

3333
ENV PATH /opt/qt6/6.8.2/gcc_64/bin:/opt/qt6/6.8.2/gcc_64/libexec:$PATH
3434

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
SHELL := /bin/bash
1616
WEBROOT := frontends/web
17-
GOPATH ?= $(HOME)/go
18-
PATH := $(PATH):$(GOPATH)/bin
1917

2018
catch:
2119
@echo "Choose a make target."

android-env.mk.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
export ANDROID_SDK_ROOT := /opt/android-sdk
22
export ANDROID_NDK_HOME := /opt/android-sdk/ndk/21.2.6472646
3-
# gomodcache location for gomobile build pkgs. Set to tmp folder, because writing access is needed.
4-
export GOMODCACHE_ROOT := /tmp/gomodcache/pkg/mod

backend/mobileserver/Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
include ../../android-env.mk.inc
22

3-
# GOMODCACHE to /tmp directory, because gomobile needs to write pkgs.
4-
# Also set -glflags to fix the vendor issue with gomobile, see: https://github.com/golang/go/issues/67927#issuecomment-2241523694
3+
# Set -glflags to fix the vendor issue with gomobile, see: https://github.com/golang/go/issues/67927#issuecomment-2241523694
54
build-android:
6-
GOMODCACHE=${GOMODCACHE_ROOT} ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android .
5+
ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android .
76
build-ios:
8-
GOMODCACHE=${GOMODCACHE_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target ios,iossimulator .
7+
gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target ios,iossimulator .
98
clean:
109
rm -f mobileserver.aar mobileserver-sources.jar

scripts/docker_install.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
1716
apt-get update
1817
apt-get install -y --no-install-recommends curl ca-certificates
1918

@@ -83,8 +82,7 @@ aqt install-qt linux desktop 6.8.2 -m qtpositioning qtserialport qtwebchannel qt
8382
npm install -g npm@10
8483
npm install -g locize-cli
8584

86-
mkdir -p /opt/go_dist
87-
curl https://dl.google.com/go/go1.22.5.linux-amd64.tar.gz | tar -xz -C /opt/go_dist
85+
curl https://dl.google.com/go/go1.22.5.linux-amd64.tar.gz | tar -xz -C /usr/local
8886

8987
# fuse is needed to run the linuxdeployqt appimage.
9088
apt-get install -y --no-install-recommends fuse

0 commit comments

Comments
 (0)