docker 容器中的 Firebase 服务适用于功能但不适用于托管

标签 firebase docker local firebase-hosting firebase-cli

我已经设置了以下容器 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

随附 docker-compose.yml 文件:
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

我跑过firebase init在我的容器镜像中处理,现在我在 src 中有以下文件结构目录:
|- .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

我跑了firebase deploy当我访问托管应用程序的 url 时,浏览器返回了 public/index.html 的内容。

但是,当我现在运行 firebase serve -o 0.0.0.0在正在运行的 docker 容器内,向 0.0.0.0:5001 发出请求返回:
// 20190920055855
// http://0.0.0.0:5001/

{
  "status": "alive"
}

这就是问题所在:对 0.0.0.0:5000 的请求返回浏览器:
This page isn’t working 
0.0.0.0 didn’t send any data.
ERR_EMPTY_RESPONSE

我已经阅读了有关 stackoverlfow 的其他答案,例如 firebase serve in docker container not visible to host os但似乎这应该是一个全有或全无的交易,托管和功能都应该失败或工作,但在托管失败时功能不工作。

我相当确定我的 firebase.json 内有问题hosting config,但考虑到它在部署时可以工作,我不确定那会如何。

最佳答案

你有没有发现这条线

ports:
    - 5000:5080

也许应该- 5000:5000不是 5080 ?

关于docker 容器中的 Firebase 服务适用于功能但不适用于托管,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58028298/

相关文章:

ios - 将 NSLog 写入设备上的本地文件 (iOS)

amazon-web-services - 具有无服务器本地环境的 AWS Cognito

r - 如何部署使用本地数据的 Shiny 应用程序

android - 将多个 firebase 目录中的所有帖子显示到 recyclerView 中

docker - 基于 Golang 的 docker 镜像构建有效,但不能基于 Scratch 的镜像

docker - 我可以在非 VT-X 机器(没有使用虚拟机)上直接运行 Docker 吗?

docker - 有没有办法全局设置/dev/shm 的大小,这样 --shm-size 标志不需要设置为 docker run 的一部分?

node.js - 带有 Yarn 工作区的 Firebase 函数

ios - 重置推送通知/设备注册/实例 ID - 通过 TestFlight 或 App Store 更新应用程序 - Firebase 云消息传递 iOS/React Native Firebase

node.js - 在 onCreate Firestore 事件后每 30 分钟运行一次 Cron 作业