Device keeps building in container


#1
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: https://docs.gradle.org/2.6/userguide/gradle_daemon.html
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

ENV INITSYSTEM=on

# Environment
ENV IVY_HOME /cache
ENV GRADLE_VERSION 2.6
ENV GRADLE_HOME /usr/local/gradle
ENV PATH ${PATH}:${GRADLE_HOME}/bin
ENV GRADLE_USER_HOME /gradle

#Change working folder for installing deps
WORKDIR /usr/local
# Install gradle
RUN wget  https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip && \
    unzip gradle-$GRADLE_VERSION-bin.zip && \
    rm -f gradle-$GRADLE_VERSION-bin.zip && \
    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 gradle.build)
RUN apk update && \
	apk add git && \
	rm -rf /var/cache/apk/*

#install musl.dev (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/github.com/streamsets

#Change focus for gradle to projectroot
WORKDIR $GOPATH/src/github.com/streamsets
ENTRYPOINT gradle

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

#Run git command init workaround because gradle.build uses git repository structure for git list command
RUN git init && \
	git config --global user.email "john@doe.com" && \
	git config --global user.name "John Doe" && \
	git add --all && \
	git commit -m "Initial commit"

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

WORKDIR $GOPATH/src/github.com/streamsets/dist
RUN chmod 0755 bin/edge

#debug
RUN pwd && ls -la bin

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

Any idea what would be wrong?


#4

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

or

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).


#5

I have to execute:

cd dist
bin/edge -debug

Can I work with:

WORKDIR $GOPATH/src/github.com/streamsets/dist
CMD bin/edge -debug

#6

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).


#7

The ENTRYPOINT entry was the problem, thanks!