Device keeps building in container

27.04.18 18:50:50 (+0200) Restarting service 'main sha256:9a019440f4eb2387491ec1ecc2498e723ab012782ead8008ff4a5e63dc150696'
27.04.18 18:42:48 (+0200) :help
27.04.18 18:42:48 (+0200) 
27.04.18 18:42:48 (+0200) Welcome to Gradle 2.6.
27.04.18 18:42:48 (+0200) 
27.04.18 18:42:48 (+0200) To run a build, run gradle <task> ...
27.04.18 18:42:48 (+0200) 
27.04.18 18:42:48 (+0200) To see a list of available tasks, run gradle tasks
27.04.18 18:42:48 (+0200) 
27.04.18 18:42:48 (+0200) To see a list of command-line options, run gradle --help
27.04.18 18:42:48 (+0200) 
27.04.18 18:42:48 (+0200) To see more detail about a task, run gradle help --task <task>
27.04.18 18:42:48 (+0200) 
27.04.18 18:42:48 (+0200) BUILD SUCCESSFUL
27.04.18 18:42:48 (+0200) 
27.04.18 18:42:49 (+0200) Total time: 2 mins 17.17 secs
27.04.18 18:42:49 (+0200) 
27.04.18 18:42:49 (+0200) This build could be faster, please consider using the Gradle Daemon:
27.04.18 18:45:29 (+0200) :help
27.04.18 18:45:29 (+0200) 
27.04.18 18:45:29 (+0200) Welcome to Gradle 2.6.

My device keeps building after a successful build (unicorn) on the resin systems and downloading the image on the device. I’m working with this buildscript (dockerfile.template)

FROM resin/%%RESIN_MACHINE_NAME%%-alpine-openjdk


# Environment
ENV GRADLE_HOME /usr/local/gradle

#Change working folder for installing deps
WORKDIR /usr/local
# Install gradle
RUN wget$ && \
    unzip gradle-$ && \
    rm -f gradle-$ && \
    ln -s gradle-$GRADLE_VERSION gradle && \
    echo -ne "- with Gradle $GRADLE_VERSION\n" >> /root/.built
#Install gradle deps
RUN apk update && \
	apk add libstdc++ && \
	rm -rf /var/cache/apk/*
RUN mkdir -p /gradle && mkdir -p /app

#install GO
RUN apk update && \
	apk add go && \
	rm -rf /var/cache/apk/*

#install Git (not on depslist datacollector-edge, but necessary for git list calls in
RUN apk update && \
	apk add git && \
	rm -rf /var/cache/apk/*

#install (not on depslist datacollector-edge, but necessary for missing files in alpine image)
RUN apk update && \
	apk add musl-dev && \
	rm -rf /var/cache/apk/*	
#Create copy folder for golang app
RUN mkdir -p $GOPATH/src/

#Change focus for gradle to projectroot

#Copy all projectfiles and directories - change owner of gradlew file
COPY ./app/ $GOPATH/src/
RUN chmod 0755 gradlew

#Run git command init workaround because uses git repository structure for git list command
RUN git init && \
	git config --global "" && \
	git config --global "John Doe" && \
	git add --all && \
	git commit -m "Initial commit"

#issue build command
RUN ./gradlew clean build
RUN chmod 0644 gradlew

RUN chmod 0755 bin/edge

RUN pwd && ls -la bin

#start datacollector-edge
CMD ["bin/edge -debug"]

Any idea what would be wrong?

You are setting an ENTRYPOINT, which

a) overwrites the resin-provided ENTRYPOINT
b) that probably runs the build, as the ENTRYPOINT + CMD might not be okay together

That CMD is not correct that way, as much as I know. It should be either

CMD bin/edge -debug


CMD ["bin/edge", "-debug"]

(notice the comma; here’s the Dockerfile CMD docs)

What is the actual command you have to run on start? The edge binary? Because then don’t define ENTRYPOINT for sure (and it’s generally recommended not to, on resin with resin base images).

I have to execute:

cd dist
bin/edge -debug

Can I work with:

CMD bin/edge -debug

Yes, it would work, I think. The point about the syntax was, that ["bin/edge -debug"] and ["bin/edge", "-debug"] is not the same, as the shell interprets every item together as one argument, and the first one is actually not a single argument, and thus evoked, it won’t behave properly. The second there is the proper form. On the other hand, just calling CMD bin/edge -debug would clear away the uncertainties (see more in the linked docs).

1 Like

The ENTRYPOINT entry was the problem, thanks!