Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase deploy fails #224

Closed
Harfish opened this issue Apr 26, 2019 · 9 comments
Closed

Firebase deploy fails #224

Harfish opened this issue Apr 26, 2019 · 9 comments

Comments

@Harfish
Copy link

Harfish commented Apr 26, 2019

Affected builder image

gcr.io/cloud-builders-community/helm

Expected Behavior

  • Deploy complete!

Actual Behavior

Pulling image: gcr.io/$PROJECT_ID/firebase
Using default tag: latest
latest: Pulling from $PROJECT_ID/firebase
e79bb959ec00: Already exists
d4b7902036fe: Already exists
1b2a72d4e030: Already exists
d54db43011fd: Already exists
69d473365bb3: Already exists
6e2490ee2dc8: Already exists
a379571b1bfc: Already exists
7b9a41966503: Already exists
f4b1c42f5c2b: Pulling fs layer
17b0c2359212: Pulling fs layer
715c6ee9925e: Pulling fs layer
17b0c2359212: Verifying Checksum
17b0c2359212: Download complete
715c6ee9925e: Verifying Checksum
715c6ee9925e: Download complete
f4b1c42f5c2b: Verifying Checksum
f4b1c42f5c2b: Download complete
f4b1c42f5c2b: Pull complete
17b0c2359212: Pull complete
715c6ee9925e: Pull complete
Digest: sha256:6445a29e9a3a5095e0ce7f01246d99a64d7942c911ef350ea7a7ee4906319617
Status: Downloaded newer image for gcr.io/$PROJECT_ID/firebase:latest
standard_init_linux.go:190: exec user process caused "no such file or directory"

Steps to Reproduce the Problem

  1. Build Docker image as documented
  2. Submit build via Google Cloud Build
  3. Build fails at final step as above

Additional Info

I have replaced the name of my actual project above with $PROJECT_ID.
Running firebase deploy from my laptop works.
Cloudbuild.yaml below
steps:

Install

  • name: 'gcr.io/cloud-builders/npm'
    args: ['install']

Build

  • name: 'gcr.io/cloud-builders/npm'
    args: ['run', 'build', '--prod']

Deploy

  • name: 'gcr.io/$PROJECT_ID/firebase'
    args: ['deploy']
@Harfish
Copy link
Author

Harfish commented Apr 28, 2019

It would seem the entrypoint as defined in the Dockerfile (firebase.bash) uses Windows-style carriage returns (CRLF), not Linux style (LF) so errors with "/bin/sh^M: bad interpreter: No such file or directory" when run. Changing to Linux style returns fixes the issue.

@Harfish Harfish closed this as completed Apr 28, 2019
@yuliankarapetkov
Copy link

Just in case anyone is wondering where to find this firebase.bash file - it is located in your local cloud-builders-community/firebase copy.

@collins-lagat
Copy link

Could somebody post the updated code?

@collins-lagat
Copy link

collins-lagat commented Oct 29, 2019

Could somebody post the updated code?

My code looks like this. It fixed my issue.
`
FROM node

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install dos2unix
RUN npm i -g firebase-tools
ADD firebase.bash /usr/bin
RUN chmod +x /usr/bin/firebase.bash
RUN dos2unix /usr/bin/firebase.bash

ENTRYPOINT [ "/usr/bin/firebase.bash" ]
`

@JosephShepin
Copy link

JosephShepin commented Sep 28, 2020

i am confused as to what the answer is, one of you is saying the solution is in the firebase.bash with the windows style carriage returns, but the code from collins-lagat says its from the dockerfile. I have tried to figure out where the issue lies but I cant figure it out
here is my dockerfile
`FROM node

RUN npm i -g firebase-tools
ADD firebase.bash /usr/bin
RUN chmod +x /usr/bin/firebase.bash

ENTRYPOINT [ "/usr/bin/firebase.bash" ]
`

and the firebase.bash

#!/bin/bash
if [ $FIREBASE_TOKEN ]; then
firebase "$@" --token $FIREBASE_TOKEN
else
firebase "$@"
fi

@collins-lagat
Copy link

i am confused as to what the answer is, one of you is saying the solution is in the firebase.bash with the windows style carriage returns, but the code from collins-lagat says its from the dockerfile. I have tried to figure out where the issue lies but I cant figure it out
here is my dockerfile
`FROM node

RUN npm i -g firebase-tools
ADD firebase.bash /usr/bin
RUN chmod +x /usr/bin/firebase.bash

ENTRYPOINT [ "/usr/bin/firebase.bash" ]
`

and the firebase.bash

#!/bin/bash
if [ $FIREBASE_TOKEN ]; then
firebase "$@" --token $FIREBASE_TOKEN
else
firebase "$@"
fi

What error are you getting?

@JosephShepin
Copy link

the same described originally above, "standard_init_linux.go:190: exec user process caused "no such file or directory"
I understand it has something to do with line endings, but I can't pinpoint where in the file there is some difference in line endings, I assume the are invisible. I am a bit new to this stuff so I really appreciate your help. I was able to get it all going from my macbook, so the line endings are certainly the issue from my windows pc, I just dont know how to solve the problem on my windows. Thanks.

@collins-lagat
Copy link

the same described originally above, "standard_init_linux.go:190: exec user process caused "no such file or directory"
I understand it has something to do with line endings, but I can't pinpoint where in the file there is some difference in line endings, I assume the are invisible. I am a bit new to this stuff so I really appreciate your help. I was able to get it all going from my macbook, so the line endings are certainly the issue from my windows pc, I just dont know how to solve the problem on my windows. Thanks.

Yeah, If you are using Windows, the way Windows saves a .bash file is different in unix like OSs like Linux and Mac. And since most Dockerfiles have a Linux base, a .bash file saved in Windows will cause an error. However, a utility app called dos2unix exists to counter this. This app converts a windows .bash file to a unix .bash file. It reverses what Windows did.
A simple way to use it is shown below:

#  Install dos2unix
RUN apt-get install dos2unix

# Convert the file
RUN dos2unix /usr/bin/firebase.bash

@JosephShepin
Copy link

Appreciate the help, have a nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants