Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install elmlang visual debug encoder ellie on docker

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install elmlang visual debug encoder ellie on docker", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to install elmlang visual debug encoder ellie on docker"!

All right, before making changes to prod's dockerfile and docker-compose.yml, change a few files in the source code:

Config: ellie, Ellie.Repo segment in configuration file config/prod.exs

Under the adpter entry, add:

Username: "postgres", password: "postgres", database: "ellie", hostname: "database", port: 5432, ssl: false

The above is the configuration to connect to the postgresql instance when the ellie container instance is started.

Database is the hostname of the host where the database resides. The database postgresql9.5 in docker-compose.yml corresponds to the ID of container, which is usually database. For that ssl, if ssl is not added, ssl not avaliable will appear at run time.

The config: logger section is also replaced by this: config: logger,: console, format: "[$level] $message\ n", otherwise the phx.server console contained by a run.sh will not give any information.

In assets/package-lock.json, find natives and upgrade its version

"natives": {"version": "1.1.6", "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz"}

The above is to prevent nodejs from making natives-related errors when compiling deps.

In dockerfile:

Add a section under DEPS to install postgresql-client:

# Install postgres-clientRUN 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

Then there is the body of dockerfile:

# Download Elm platform binariesRUN 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/*\ # the above are the original logic for preparing the binaries of elmlang to tmp The following prepares the entire app execution environment, named tmp2 to list these two steps in a corresponding manner # the tmp2 here actually corresponds to add in the original dockerfile. / app, it's just that the original build is fine when running on a stand-alone machine, and when you run on a migration and installation to another docker host, you will be prompted that the file cannot be found (the correct top level of app cannot be located. So when you deps.get, you can't find package.json, etc., and entrypoint can't find run.sh. You can see how many times you build the original dockerfile and compare it here. # you may have noticed this long RUN, which keeps all the logic for generating app in one RUN, otherwise it will exceed the hierarchical file system of docker build and cause unexpected things to happen. Guess the original add. / app is not maintained on the same file system. Volume in docker-compose.yml will also fail to take effect. & & 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\ # install all extensions related to elixir and generate the project database file & & cd / tmp2\ & & mix deps.get\ & & mix compile\ & & mix do loadpaths Absinthe.schema.json / tmp2/priv/graphql/schema.json\ # # install all nodejs-related extensions And generate the webpack static file of the project & & cd / tmp2/assets\ & & npm install\ & & npm run graphql\ & & npm run build

At this point, the resources that build all the project runtimes are built.

It's almost up and running. When preparing the predefined parameters of ENV, docker run will fail to enter the instance: ENV MIX_ENV=prod\ NODE_ENV=production\ PORT=4000\ ELM_HOME=/tmp2/priv/elm_home\ SECRET_KEY_BASE= "+ ODF8PyQMpBDb5mxA117MqkLne/bGi0PZoTl5uIHAzck2hDAJ8uGJPzark0Aolyi" definition the main function of running # WORKDIR is to define all the following instructions, especially the path WORKDIR / tmp2EXPOSE 4000RUN chmod + x / tmp2/run.shENTRYPOINT of entrypoint, etc. ["/ tmp2/run.sh"]

This run.sh is the entrypoint that separates the container where postgresql resides from the container where ellie resides. All the initialization of the connection database must be done here, because it inherits the pre-embedded parameters of ENV about prod, so the runtime will not make errors. Otherwise, in the case of non-docker builds, if you execute mix phx.server on the command line alone, you will get the following error: (EXIT) no process: the process is not alive or there's no process currently associated with the given name. You need to export all these parameters in run.sh, which is also a requirement for docker's federated file system to be logically synchronized at different stages of compilation (dockerfile) / run (run.sh).

The content of run.sh (it is a new file to be added to git repos and needs to be submitted to the new git repos): #! / usr/bin/env bashset-ecd / tmp2until PGPASSWORD=postgres psql-h "database"-U "postgres"-c'\ Q; do > & 2 echo "Postgres is unavailable-sleeping" sleep 5donemix ecto.createmix ecto.migratemix phx.server finally, docker-compose.yml is clear at a glance. Ellie: image: minlearn/ellie-corrected links:-database:database ports:-4000 restart: always environment:-SERVER_HOST=52.81.25.39database: image: postgres:9.5 environment:-POSTGRES_PASSWORD=postgres restart: always

Minlearn/ellie-corrected is the correct ellie I compiled on dockerhub. In fact, the volumes of ellie above also doesn't work. Leave it to others (this is the great inconvenience caused by hierarchical file systems). Anyway, the project can be deployed to any machine that supports docker and can start and enter the interface of the IP:4000 where ellie is located.

Assuming that the above does not add SERVER_HOST, you will find that ip:4000/new shows ellie animation, but always hangout, the console shows, [error] Could not check origin for Phoenix.Socket transport.

This requires setting the SERVER_HOST=ip variable (this ip is the public network IP of the machine where you deploy the ellie or the IP where the accessed IP:4000 is located). This variable cannot be placed in the dockerfile or in the run.sh (because these two files are to be put into the docker image, and you can't predict which host of the IP to put the docker image on), so put it in the ellie section of the docker-compose.yml and specify it when you actually open the ellie container. For example, the IP for my deployment runtime is 52.81.25.39.

Thank you for your reading, the above is the content of "how to install elmlang visual debug encoder ellie on docker". After the study of this article, I believe you have a deeper understanding of how to install elmlang visual debug encoder ellie on docker, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report