-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
57 lines (38 loc) · 1.24 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -x
#
# Assumption: 'rpi_temp' project is located at: $GOPATH/src/$PACKAGE_ROOT/rpi_temp
#
PACKAGE_ROOT=github.com/jens18
# compile Go program
#
# generate static binaries to enable use of (very small) luxas/alpine Docker base image
#
# see the section on etcd and influxdb in the following Kubernetes-on-arm build script:
# https://github.com/luxas/kubernetes-on-arm/blob/master/images/kubernetesonarm/build/inbuild.sh
#
# NOTE: GOPATH is expected to to be set to this directory.
# download dependencies:
# go get github.com/gorilla/mux
# compile:
CGO_ENABLED=0 go build -ldflags "-extldflags '-static'" rpi_temp.go
CGO_ENABLED=0 go build -ldflags "-extldflags '-static'" kube_temp.go
# 'go install does produce the following error:
# go install net: open /usr/local/go/pkg/linux_amd64/net.a: permission denied
# install:
# ensure bin directory exists
mkdir -p $GOPATH/bin
# copy executable file
cp rpi_temp $GOPATH/bin
# generate Docker image
# 'uname -m' to identify the required Dockerfile:
# RPI 1: armv6l
# RPI 3: armv7l
# PC: x86_64
# RPI 3 and RPI 1 can use the same Dockerfile: Dockerfile.armv6l
MACHINE=`uname -m`
if [ $MACHINE == "armv7l" ]
then
MACHINE="armv6l"
fi
docker build -f Dockerfile.$MACHINE -t rpi_temp .