diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index bf3155b5..f3b42dd6 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -32,8 +32,8 @@ RUN chmod +x /app/src/enterContainer.sh \ && /app/node_modules/.bin/coffee -c /app/src \ && ln -sf /app/entry.sh /start # Needed for legacy -RUN mv /app/gosuper/bin/linux_amd64/gosuper /app/gosuper/bin/ -RUN chmod +x /app/gosuper/bin/gosuper +RUN mv /app/gosuper/bin/linux_amd64/gosuper /app/gosuper/bin/ && \ + chmod +x /app/gosuper/bin/gosuper ENV SUPERVISOR_IMAGE resin/amd64-supervisor ENV CONFIG_MOUNT_POINT /boot/config.json diff --git a/Dockerfile.armv7hf b/Dockerfile.armv7hf index 5e1ba52f..8cefaff7 100644 --- a/Dockerfile.armv7hf +++ b/Dockerfile.armv7hf @@ -32,8 +32,8 @@ RUN chmod +x /app/src/enterContainer.sh \ && /app/node_modules/.bin/coffee -c /app/src \ && ln -sf /app/entry.sh /start # Needed for legacy -RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/ -RUN chmod +x /app/gosuper/bin/gosuper +RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/ && \ + chmod +x /app/gosuper/bin/gosuper ENV SUPERVISOR_IMAGE resin/armv7hf-supervisor ENV CONFIG_MOUNT_POINT /boot/config.json diff --git a/Dockerfile.gosuper b/Dockerfile.gosuper index 80fa65c0..333b71b4 100644 --- a/Dockerfile.gosuper +++ b/Dockerfile.gosuper @@ -1,12 +1,12 @@ FROM golang:1.4.2-cross -COPY . /usr/src/app/src/resin-supervisor - ENV GOOS linux ENV GOPATH /usr/src/app WORKDIR /usr/src/app +COPY . src/resin-supervisor + RUN chmod +x src/resin-supervisor/build_gosuper.sh # Run go install with -a (force rebuilding of all packages) diff --git a/Dockerfile.i386 b/Dockerfile.i386 index 41875b49..12e9992f 100644 --- a/Dockerfile.i386 +++ b/Dockerfile.i386 @@ -32,8 +32,8 @@ RUN chmod +x /app/src/enterContainer.sh \ && /app/node_modules/.bin/coffee -c /app/src \ && ln -sf /app/entry.sh /start # Needed for legacy -RUN mv /app/gosuper/bin/linux_386/gosuper /app/gosuper/bin/ -RUN chmod +x /app/gosuper/bin/gosuper +RUN mv /app/gosuper/bin/linux_386/gosuper /app/gosuper/bin/ && \ + chmod +x /app/gosuper/bin/gosuper ENV SUPERVISOR_IMAGE resin/i386-supervisor ENV CONFIG_MOUNT_POINT /boot/config.json diff --git a/Dockerfile.rpi b/Dockerfile.rpi index c47af129..6488c257 100644 --- a/Dockerfile.rpi +++ b/Dockerfile.rpi @@ -32,7 +32,7 @@ RUN chmod +x /app/src/enterContainer.sh \ && /app/node_modules/.bin/coffee -c /app/src \ && ln -sf /app/entry.sh /start # Needed for legacy -RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/ -RUN chmod +x /app/gosuper/bin/gosuper +RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/ && \ + chmod +x /app/gosuper/bin/gosuper CMD ["/app/entry.sh"] diff --git a/Makefile b/Makefile index 75f302da..ce0490e9 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,9 @@ go-builder: gosuper: go-builder -mkdir -p gosuper/bin - docker run -v $(shell pwd)/gosuper/bin:/usr/src/app/bin -e GOARCH=$(GOARCH) resin/go-supervisor-builder:$(SUPERVISOR_VERSION) + docker run -v $(shell pwd)/gosuper/bin:/usr/src/app/bin -e USER_ID=$(shell id -u) -e GROUP_ID=$(shell id -g) -e GOARCH=$(GOARCH) resin/go-supervisor-builder:$(SUPERVISOR_VERSION) + +test-gosuper: go-builder + docker run -v $(shell pwd)/gosuper/bin:/usr/src/app/bin resin/go-supervisor-builder:$(SUPERVISOR_VERSION) bash -c "cd src/resin-supervisor && go test -v ./..." .PHONY: supervisor deploy supervisor-dind run-supervisor diff --git a/automation/jenkins_build.sh b/automation/jenkins_build.sh index 71a5b182..f9321ff9 100755 --- a/automation/jenkins_build.sh +++ b/automation/jenkins_build.sh @@ -8,6 +8,9 @@ ESCAPED_BRANCH_NAME=$(echo $sourceBranch | sed 's/[^a-z0-9A-Z_.-]/-/g') # Try pulling the old build first for caching purposes. docker pull resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME} || docker pull resin/${ARCH}-supervisor:master || true +# Test the gosuper +make SUPERVISOR_VERSION=${VERSION} test-gosuper + # Build the images make SUPERVISOR_VERSION=${ESCAPED_BRANCH_NAME} ARCH=${ARCH} DEPLOY_REGISTRY= deploy make SUPERVISOR_VERSION=${VERSION} ARCH=${ARCH} DEPLOY_REGISTRY= deploy diff --git a/build_gosuper.sh b/build_gosuper.sh index 66f290be..5cef11a6 100644 --- a/build_gosuper.sh +++ b/build_gosuper.sh @@ -1,12 +1,13 @@ #!/bin/bash -set -e go install -a -v ./... +RETURN_VALUE=$? # For consistency, always keep the binary within a linux_$GOARCH folder -if (( $GOARCH == "amd64" )); then +if [ $GOARCH == "amd64" ]; then mkdir $GOPATH/bin/linux_$GOARCH || true cp $GOPATH/bin/gosuper $GOPATH/bin/linux_$GOARCH/ fi -chmod -R a+rwx $GOPATH/bin - \ No newline at end of file +chown -R $USER_ID:$GROUP_ID $GOPATH/bin + +exit $RETURN_VALUE diff --git a/gosuper/config.go b/gosuper/config.go index 2130a073..626c9633 100644 --- a/gosuper/config.go +++ b/gosuper/config.go @@ -2,7 +2,7 @@ package main import ( "encoding/json" - "os" + "io/ioutil" ) type UserConfig struct { @@ -20,19 +20,13 @@ func ReadConfig(path string) (UserConfig, error) { var config UserConfig - f, err := os.Open(path) - if err != nil { - return config, err - } - data := make([]byte, 1000) - - count, err := f.Read(data) + data, err := ioutil.ReadFile(path) if err != nil { return config, err } - err = json.Unmarshal(data[:count], &config) + err = json.Unmarshal(data, &config) return config, err }