這篇文章主要講解了“怎么在docker上裝elmlang可視調(diào)試編碼器ellie”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“怎么在docker上裝elmlang可視調(diào)試編碼器ellie”吧!
我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、瓊山ssl等。為1000+企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的瓊山網(wǎng)站制作公司
好了,在針對(duì)prod的dockerfile和docker-compose.yml作修改之前,先改幾個(gè)源碼中的文件:
在adpter條目下增加:
username: "postgres", password: "postgres", database: "ellie", hostname: "database", port: 5432, ssl: false,
以上是ellie container實(shí)例啟動(dòng)時(shí)連接postgresql實(shí)例的配置。
database是數(shù)據(jù)庫(kù)所在主機(jī)的主機(jī)名,docker-compose.yml中數(shù)據(jù)庫(kù) postgresql9.5對(duì)應(yīng)container的ID,一般是database,對(duì)于那個(gè)ssl,如果不加ssl,會(huì)在運(yùn)行時(shí)出現(xiàn)ssl not avaliable
config :logger段也換成這個(gè):config :logger, :console, format: "[$level] $message\n",否則接下來(lái)被一個(gè)run.sh包含的phx.server控制臺(tái)不出任何信息。
"natives": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz" },
以上是為了在防止nodejs在編譯deps時(shí)出現(xiàn)natives有關(guān)的錯(cuò)誤。
DEPS下加一段安裝postgresql-client:
# Install postgres-client RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" >> /etc/apt/sources.list.d/pgdg.list \ && wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add - \ && apt-get update \ && apt-get -yq --no-install-recommends install inotify-tools postgresql-client-9.5
然后就是dockerfile主體部分了:
# Download Elm platform binaries RUN mkdir -p /tmp/elm_bin/0.18.0 && mkdir -p /tmp/elm_bin/0.19.0 \ # goon executable for Procelain Elixir library, to run executables in Elixir processes && wget -q https://github.com/alco/goon/releases/download/v1.1.1/goon_linux_386.tar.gz -O /tmp/goon.tar.gz \ && tar -xvC /tmp/elm_bin -f /tmp/goon.tar.gz \ && chmod +x /tmp/elm_bin/goon \ && rm /tmp/goon.tar.gz \ # Elm Platform 0.18 && wget -q https://github.com/elm-lang/elm-platform/releases/download/0.18.0-exp/elm-platform-linux-64bit.tar.gz -O /tmp/platform-0.18.0.tar.gz \ && tar -xvC /tmp/elm_bin/0.18.0 -f /tmp/platform-0.18.0.tar.gz \ && rm /tmp/platform-0.18.0.tar.gz \ # Elm Format 0.18 && wget -q https://github.com/avh5/elm-format/releases/download/0.7.0-exp/elm-format-0.18-0.7.0-exp-linux-x64.tgz -O /tmp/format-0.18.0.tar.gz \ && tar -xvC /tmp/elm_bin/0.18.0 -f /tmp/format-0.18.0.tar.gz \ && rm /tmp/format-0.18.0.tar.gz \ && chmod +x /tmp/elm_bin/0.18.0/* \ # Elm Platform 0.19 && wget -q https://github.com/elm/compiler/releases/download/0.19.0/binaries-for-linux.tar.gz -O /tmp/platform-0.19.0.tar.gz \ && tar -xvC /tmp/elm_bin/0.19.0 -f /tmp/platform-0.19.0.tar.gz \ && rm /tmp/platform-0.19.0.tar.gz \ && chmod +x /tmp/elm_bin/0.19.0/* \ # Elm Format 0.19 && wget -q https://github.com/avh5/elm-format/releases/download/0.8.0-rc3/elm-format-0.19-0.8.0-rc3-linux-x64.tgz -O /tmp/format-0.19.0.tar.gz \ && tar -xvC /tmp/elm_bin/0.19.0 -f /tmp/format-0.19.0.tar.gz \ && rm /tmp/format-0.19.0.tar.gz \ && chmod +x /tmp/elm_bin/0.19.0/* \ # 以上都是準(zhǔn)備elmlang的binaries到tmp下的原邏輯,,以下準(zhǔn)備整個(gè)app執(zhí)行環(huán)境,命名為tmp2是為了將這二步驟以對(duì)應(yīng)的方式列出。 # 這里的tmp2,其實(shí)對(duì)應(yīng)原版的dockerfile中是 add . /app,只是原版的構(gòu)建出來(lái)在單機(jī)跑起來(lái)沒(méi)事,在遷移安裝到別的docker主機(jī)上跑起來(lái),會(huì)提示找不到文件(定位不到正確的app頂層。所以deps.get時(shí)會(huì)找不到package.json等,entrypoint也找不到run.sh)。你多構(gòu)建幾次原版dockerfile與這里對(duì)比就知道了。 # 你可能已經(jīng)注意到這條很長(zhǎng)的RUN,它將所有關(guān)于生成app的邏輯都維持在一個(gè)RUN中,否則就超了docker構(gòu)建時(shí)的分層文件系統(tǒng)了,會(huì)導(dǎo)致不意料的事情發(fā)生。猜測(cè)原版 add . /app 就是沒(méi)有維持在同一個(gè)文件系統(tǒng)中。docker-compose.yml中的volume也會(huì)不能生效。 && git clone https://github.com/minlearn/ellie-corrected /tmp2 \ && mkdir -p /tmp2/priv/bin \ && cp -r /tmp/elm_bin/* /tmp2/priv/bin \ && mkdir -p /tmp2/priv/elm_home \ # 安裝elixir相關(guān)的所有擴(kuò)展并生成項(xiàng)目的數(shù)據(jù)庫(kù)文件 && cd /tmp2 \ && mix deps.get \ && mix compile \ && mix do loadpaths, absinthe.schema.json /tmp2/priv/graphql/schema.json \ ## 安裝nodejs相關(guān)的所有擴(kuò)展,并生成項(xiàng)目的webpack靜態(tài)文件 && cd /tmp2/assets \ && npm install \ && npm run graphql \ && npm run build
至此,生成構(gòu)建了所有項(xiàng)目運(yùn)行時(shí)的資源。
ENV MIX_ENV=prod \ NODE_ENV=production \ PORT=4000 \ ELM_HOME=/tmp2/priv/elm_home \ SECRET_KEY_BASE="+ODF8PyQMpBDb5mxA117MqkLne/bGi0PZoTl5uIHAzck2hDAJ8uGJPzark0Aolyi"
# WORKDIR的主要作用就是定義接下來(lái)所有指令,尤其是entrypoint等的路徑 WORKDIR /tmp2 EXPOSE 4000 RUN chmod +x /tmp2/run.sh ENTRYPOINT ["/tmp2/run.sh"]
這個(gè)run.sh是分離postgresql所在容器和ellie所在容器的entrypoint,所有連接數(shù)據(jù)庫(kù)初始化的工作都要在這里完成,因?yàn)樗^承了ENV關(guān)于prod的預(yù)埋參數(shù)所以運(yùn)行時(shí)不會(huì)出錯(cuò),否則比如在非docker構(gòu)建的情況下,你把mix phx.server單獨(dú)在命令行中執(zhí)行,會(huì)出現(xiàn)如下錯(cuò)誤:(EXIT) no process: the process is not alive or there's no process currently associated with the given name。你就需要在run.sh中export所有這些參數(shù),這也是docker的聯(lián)合文件系統(tǒng)在編譯(dockerfile)/運(yùn)行(run.sh)不同階段需要做到邏輯同步的要求。
#! /usr/bin/env bash set -e cd /tmp2 until PGPASSWORD=postgres psql -h "database" -U "postgres" -c '\q'; do >&2 echo "Postgres is unavailable - sleeping" sleep 5 done mix ecto.create mix ecto.migrate mix phx.server
ellie: image: minlearn/ellie-corrected links: - database:database ports: - 4000:4000 restart: always environment: - SERVER_HOST=52.81.25.39 database: image: postgres:9.5 environment: - POSTGRES_PASSWORD=postgres restart: always
minlearn/ellie-corrected是我在dockerhub上編譯正確的ellie,實(shí)際上,上面的ellie的volumes同樣是沒(méi)有起作用的。留給其它人解決吧(這就是分層文件系統(tǒng)給人理解上帶來(lái)的極大不便)。反正項(xiàng)目部署到任何支持docker的機(jī)器都可以啟動(dòng)并進(jìn)入ellie所在IP:4000的界面了。
假設(shè)上面的沒(méi)加SERVER_HOST,進(jìn)去你會(huì)發(fā)現(xiàn)ip:4000/new顯示ellie的動(dòng)畫,但一直hangout,控制臺(tái)顯示,[error] Could not check origin for Phoenix.Socket transport.
這就需要設(shè)置SERVER_HOST=ip變量了(這個(gè)ip是你部署ellie所在機(jī)器的外網(wǎng)IP或被訪問(wèn)IP:4000所在的IP),這個(gè)變量不能放在dockerfile中,也不能放在run.sh中(因?yàn)檫@二個(gè)文件要做進(jìn)docker image中的,而你無(wú)法預(yù)知要將這個(gè)docker image放哪個(gè)IP的主機(jī)上),故要放在docker-compose.yml中ellie段下在實(shí)際開啟ellie container時(shí)指定,比如我部署運(yùn)行時(shí)的IP是52.81.25.39。
感謝各位的閱讀,以上就是“怎么在docker上裝elmlang可視調(diào)試編碼器ellie”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)怎么在docker上裝elmlang可視調(diào)試編碼器ellie這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
當(dāng)前文章:怎么在docker上裝elmlang可視調(diào)試編碼器ellie
網(wǎng)頁(yè)URL:http://chinadenli.net/article38/giegpp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、微信公眾號(hào)、網(wǎng)站營(yíng)銷、響應(yīng)式網(wǎng)站、網(wǎng)站策劃、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)