【发布时间】:2020-07-21 22:11:07
【问题描述】:
所以我在 heroku 上部署了一个应用程序,部署后,它说它在 localhost:5000 上运行。我想使用 $PORT 变量公开这个端口。执行此操作的确切命令是什么?这是相关的:https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime,但是如何真正公开端口?这就是我的 Dockerfile 的样子:
# We will use Ubuntu for our image
FROM ubuntu:latest
# Updating Ubuntu packages
ARG CLOJURE_TOOLS_VERSION=1.10.1.507
RUN apt-get -qq update && apt-get -qq -y install curl wget bzip2 openjdk-8-jdk-headless \
&& curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh \
&& bash /tmp/miniconda.sh -bfp /usr/local \
&& rm -rf /tmp/miniconda.sh \
&& conda install -y python=3 \
&& conda update conda \
&& curl -o install-clojure https://download.clojure.org/install/linux-install-${CLOJURE_TOOLS_VERSION}.sh \
&& chmod +x install-clojure \
&& ./install-clojure && rm install-clojure \
&& wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
&& chmod a+x lein \
&& mv lein /usr/bin \
&& apt-get -qq -y autoremove \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log \
&& conda clean --all --yes
ENV PATH /opt/conda/bin:$PATH
RUN conda create -n pyclj python=3.6 && conda install -n pyclj numpy mxnet
## To install pip packages into the pyclj environment do
RUN conda run -n pyclj python3 -mpip install numpy
#COPY . .
RUN lein uberjar
RUN java $JVM_OPTS -cp target/myapp.jar clojure.main -m myapp.application --server.port=$PORT
https://github.com/heroku/alpinehelloworld/blob/master/Dockerfile 此处的 Dockerfile 示例显示了 gunicorn 命令,但我的项目到目前为止还没有使用 gunicorn。如何配置我的 Dockerfile 以便我的应用程序使用 $PORT 环境变量?
我正在使用 aleph.io:
(ns myapp.application
(:gen-class)
(:require ;; more requires
[system.components.aleph :refer [new-web-server]]
))
(defn app-system [config]
(component/system-map
:routes (new-endpoint home-routes)
:middleware (new-middleware {:middleware (:middleware config)})
:handler (-> (new-handler :router :bidi
)
(component/using [:routes :middleware]))
:http (-> (new-web-server (:http-port config) :handler)
(component/using [:handler]))
:server-info (server-info (:http-port config))))
(defn -main [& _]
(let [config (config)]
(-> config
app-system
component/start)))
【问题讨论】: