Skip to content

firebase serve in docker works for functions but not hosting #1666

@noah-goodrich

Description

@noah-goodrich

I've already seen this issue: #929 which adding the -o flag made it so functions would start working but hosting is still returning a ERR_EMPTY_RESPONSE from port 5000.

I've set up the following container Dockerfile:
FROM devillex/docker-firebase

ENV USER=app

RUN apt-get update && apt-get install -y openssl \
        libssl-dev \
        bash \
        less \
        vim \
        gnupg \
        curl \
        net-tools \
        apt-transport-https \
        ca-certificates; \
    CLOUD_SDK_REPO="cloud-sdk-$(grep VERSION_CODENAME /etc/os-release | cut -d '=' -f 2)" &&\
    echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list &&\
    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -; \
    apt-get update && apt-get install -y \
        google-cloud-sdk \
        google-cloud-sdk-cloud-build-local &&\
    gcloud config set project request-a-dance

RUN adduser --disabled-password --gecos "" --shell /bin/bash $USER &&\
    mkdir /home/app/src &&\
    npm install firebase-tools mocha standard

USER app
WORKDIR /home/app/src

EXPOSE 5000 5001 9005

With an accompanying docker-compose.yml file:

version: '3.3'
services:
  firebase:
    image: firebase:local
    hostname: "firebase-local"
    build:
      context: ../..
      dockerfile: docker/local/Dockerfile
    volumes:
      - ~/.config:/home/app/.config
      - ~/.bash_aliases:/home/app/.bash_aliases:ro
      - ~/.bashrc:/home/app/.bashrc:ro
      - ../../src:/home/app/src/
    ports:
        - 5000:5080
        - 5001:5001
        - 9005:9005
    tty: true

I ran through the firebase init process inside my container image and now I have the following file structure inside the src directory:

|- .firebase
|- .firebaserc
|- .gitignore
|- firebase-debug.log
|- firebase.json
|- firestore.indexes.json
|- firestore.rules
|- functions
  |- index.js
  |- node_modules
  |- package.json
  |- package-lock.json
|- public
  |- index.html

I ran firebase deploy and when I visited the url for my hosted app, the browser returned the contents of public/index.html

However when I now run firebase serve -o 0.0.0.0 inside the running docker container, requests to 0.0.0.0:5001 return:

// 20190920055855
// http://0.0.0.0:5001/

{
  "status": "alive"
}

And here is the problem: requests to 0.0.0.0:5000 return to the browser:

This page isn’t working 
0.0.0.0 didn’t send any data.
ERR_EMPTY_RESPONSE

I've read through other answers on stackoverlfow such as https://stackoverflow.com/q/42764151/20178 but it seems like this should be an all or nothing deal, both hosting and functions should fail or work but not functions work while hosting fails.

I'm fairly certain that something is off within my firebase.json hosting config, but given that it works when deployed I'm not sure how that would be.

This issue is being cross posted from stackoverflow: https://stackoverflow.com/q/58028298/20178

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions