【发布时间】:2019-09-20 12:21:27
【问题描述】:
我已经设置了以下容器 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,当我访问托管应用的网址时,浏览器返回了public/index.html的内容
但是,当我现在在正在运行的 docker 容器中运行 firebase serve -o 0.0.0.0 时,对 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 配置中有问题,但考虑到它在部署时可以工作,我不确定会是怎样。
【问题讨论】:
-
你发现
ports: - 5000:5080这行了吗?也许应该- 5000:5000而不是5080? -
@zzeroo 您的仔细阅读花了我几天的时间,并创建了一个简单的快速服务器以最终发现。请重新发布作为答案,赏金全是你的。哇!
-
您希望得到回答的边界问题是什么?
标签: firebase docker local firebase-hosting firebase-cli