umputun / remark42

comment engine
https://remark42.com
MIT License
4.92k stars 386 forks source link

Can't build; /script/version.sh: not found #994

Closed GiovanH closed 3 years ago

GiovanH commented 3 years ago

In a recent change, the dockerfile versioning system was changed from using /script/git-rev.sh to /script/version.sh. After updating to the latest version, building a binary gives this error:

$ make OS=linux ARCH=amd64

docker build -f Dockerfile.artifacts -t remark42.bin .
Sending build context to Docker daemon  49.14MB
Step 1/35 : FROM node:12.16-alpine as build-frontend-deps
 ---> 7a48db49edbf
Step 2/35 : ARG CI
 ---> Using cache
 ---> 5d42b0d89126
Step 3/35 : ARG DRONE
 ---> Using cache
 ---> 578fb7c9003c
Step 4/35 : ARG DRONE_TAG
 ---> Using cache
 ---> 04c5a198f7ac
Step 5/35 : ARG DRONE_COMMIT
 ---> Using cache
 ---> 2475a302183f
Step 6/35 : ARG DRONE_BRANCH
 ---> Using cache
 ---> 2d95741f715e
Step 7/35 : ENV SKIP_FRONTEND_TEST=true
 ---> Using cache
 ---> 86c1a952fcff
Step 8/35 : RUN apk add --no-cache --update git
 ---> Using cache
 ---> 3c901c5d4d33
Step 9/35 : ADD frontend/package.json /srv/frontend/package.json
 ---> Using cache
 ---> 71fe916e8da0
Step 10/35 : ADD frontend/package-lock.json /srv/frontend/package-lock.json
 ---> Using cache
 ---> 78729b70ac23
Step 11/35 : RUN cd /srv/frontend && CI=true npm ci
 ---> Using cache
 ---> c939f589440d
Step 12/35 : FROM node:12.16-alpine as build-frontend
 ---> 7a48db49edbf
Step 13/35 : ARG CI
 ---> Using cache
 ---> 5d42b0d89126
Step 14/35 : ARG NODE_ENV=production
 ---> Using cache
 ---> abc99ab7e6d2
Step 15/35 : ENV SKIP_FRONTEND_TEST=true
 ---> Using cache
 ---> b1e6380067e2
Step 16/35 : ENV HUSKY_SKIP_INSTALL=true
 ---> Using cache
 ---> 504655f8635b
Step 17/35 : COPY --from=build-frontend-deps /srv/frontend/node_modules /srv/frontend/node_modules
 ---> Using cache
 ---> 07eba667620c
Step 18/35 : ADD frontend /srv/frontend
 ---> Using cache
 ---> cffcff9dd50d
Step 19/35 : RUN cd /srv/frontend &&     npm run build &&     rm -rf ./node_modules
 ---> Using cache
 ---> e28d581efaca
Step 20/35 : FROM umputun/baseimage:buildgo-latest as build-backend
 ---> 338b8b8da600
Step 21/35 : ARG GITHUB_TOKEN
 ---> Using cache
 ---> fb77bdf82156
Step 22/35 : ENV SKIP_BACKEND_TEST=true
 ---> Using cache
 ---> 50f8445819f6
Step 23/35 : WORKDIR /build/backend
 ---> Using cache
 ---> 2137b73d5069
Step 24/35 : ADD backend /build/backend
 ---> Using cache
 ---> 0296629e3d84
Step 25/35 : ADD README.md /build/
 ---> Using cache
 ---> f293964f3529
Step 26/35 : ADD LICENSE /build/
 ---> Using cache
 ---> 9ebb52238e29
Step 27/35 : ADD .git/ /build/backend/.git/
 ---> Using cache
 ---> f7a17598b024
Step 28/35 : COPY --from=build-frontend /srv/frontend/public/ web
 ---> Using cache
 ---> 610f4526e196
Step 29/35 : RUN     export WEB_ROOT=/build/backend/web &&     find . -regex '.*\.\(html\|js\|mjs\)$' -print -exec sed -i "s|{% REMARK_URL %}|http://127.0.0.1:8080|g" {} \; &&     statik --src=${WEB_ROOT} --dest=/build/backend/app/rest -p api -f &&     statik --src=/build/backend/templates --dest=/build/backend/app -p templates -ns templates -f &&     ls -la /build/backend/app/templates/statik.go &&     ls -la /build/backend/app/rest/api/statik.go &&     ls -la /build/backend/web/
 ---> Using cache
 ---> 4a57117358ae
Step 30/35 : RUN     if [ -z "$DRONE" ] ; then     echo "runs outside of drone" && version=$("/script/version.sh");     else version=${DRONE_TAG}${DRONE_BRANCH}${DRONE_PULL_REQUEST}-${DRONE_COMMIT:0:7}-$(date +%Y%m%d-%H:%M:%S); fi &&     echo "version=$version" &&     export GOFLAGS="-mod=vendor" &&     GOOS=linux GOARCH=amd64 go build -o remark42.linux-amd64 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=linux GOARCH=386 go build -o remark42.linux-386 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=linux GOARCH=arm go build -o remark42.linux-arm -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=linux GOARCH=arm64 go build -o remark42.linux-arm64 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=windows GOARCH=amd64 go build -o remark42.windows-amd64.exe -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=darwin GOARCH=amd64 go build -o remark42.darwin-amd64 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=freebsd GOARCH=amd64 go build -o remark42.freebsd-amd64 -ldflags "-X main.revision=${version} -s -w" ./app
 ---> Running in 51f0b4ed2b88
/bin/sh: /script/version.sh: not found
runs outside of drone
The command '/bin/sh -c if [ -z "$DRONE" ] ; then     echo "runs outside of drone" && version=$("/script/version.sh");     else version=${DRONE_TAG}${DRONE_BRANCH}${DRONE_PULL_REQUEST}-${DRONE_COMMIT:0:7}-$(date +%Y%m%d-%H:%M:%S); fi &&     echo "version=$version" &&     export GOFLAGS="-mod=vendor" &&     GOOS=linux GOARCH=amd64 go build -o remark42.linux-amd64 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=linux GOARCH=386 go build -o remark42.linux-386 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=linux GOARCH=arm go build -o remark42.linux-arm -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=linux GOARCH=arm64 go build -o remark42.linux-arm64 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=windows GOARCH=amd64 go build -o remark42.windows-amd64.exe -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=darwin GOARCH=amd64 go build -o remark42.darwin-amd64 -ldflags "-X main.revision=${version} -s -w" ./app &&     GOOS=freebsd GOARCH=amd64 go build -o remark42.freebsd-amd64 -ldflags "-X main.revision=${version} -s -w" ./app' returned a non-zero code: 127
make: *** [Makefile:5: bin] Error 127
GiovanH commented 3 years ago

Reverting d3bd966df8e2a6eda2343c2adb833ea01a1157f7 seems to fix the issue.

umputun commented 3 years ago

you should pull umputun/baseimage:buildgo-latest

GiovanH commented 3 years ago

Resolved with 19ba43b8436b741779c7bb595031652954a8d8e0?

umputun commented 3 years ago

no, it wasn't a problem, and the change unrelated. As you can see Dockerfile.artifact always used latest

All you need to do in order to build it, is to make sure your umputun/baseimage:buildgo-latest fresh, i.e. docker pull umputun/baseimage:buildgo-latest

GiovanH commented 3 years ago

So you can't build from master, you can only build from that side branch? And that's intended?

umputun commented 3 years ago

you can build from master as well as any other branch. All you need in order to build it is to pull the image as I described above.

GiovanH commented 3 years ago

Oh, no, sorry for the confusion. I'm describing the dockerless workflow, where you build from binary instead of building a docker image.

umputun commented 3 years ago

yeah, still relevant as for dockless workflow you still build in docker. Your original message shows the command you used - docker build -f Dockerfile.artifacts -t remark42.bin .. Try to run docker pull umputun/baseimage:buildgo-latest first and you could run your docker build -f Dockerfile.artifacts -t remark42.bin . after this without any issue.

umputun commented 3 years ago

@GiovanH did pull solve the build problem?

GiovanH commented 3 years ago

Haven't gotten a chance to test this yet, but the only command I ran in the example I gave was make OS=linux ARCH=amd64; the docker commands were part of the makefile. Perhaps this is as simple as adding a line to the makefile

umputun commented 3 years ago

ah, I see. you expected make to take care of this, and this is a reasonable expectation. I have added options to ensure fresh images get pulled.