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