ambareesha7

ambareesha7

How to run cli command from container_1 onto in container_2 in a docker-compose setup

I have Elixir/Phoenix server, based on user requirements server generates markdown and latex files, then it runs System.cmd("pandoc", [relevant commands]) to generate PDF files everything works fine in the local system, here the dependencies are (pandoc and latex) installed locally

now I’m trying to dockerize the project.
I tried installing pandoc and latex in phoenix_server container and it worked fine but the final docker image size increased to 8.5GB because texlive itself has 7.5GB so its not an option

I found this pandoc/latex:2.18 image

so my idea is to create 3 docker containers and run docker-compose up

container_1: Phoenix_server
container_2: postgres:14
container_3: pandoc/latex:2.18

but it didn’t worked.

challenges:

1 sharing server generated file’s with pandoc/latex container, for this I’m thinking to using docker volume option

2 I could not figure out how to run cli commands from phoenix container onto in pandoc/latex container

any help is greatly appreciated

Thank you

Marked As Solved

ambareesha7

ambareesha7

I figured out how to reduce docker image size and install all dependencies in same phoenix container through lot of trial and errors current image size is 2.23gb from 8.5gb
the Dockerfile contains this now:

FROM hexpm/elixir:1.13.0-erlang-24.0.5-ubuntu-focal-20210325

RUN apt-get update && \
    apt-get install -y \
    postgresql-client inotify-tools 

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
    build-essential xorg libssl-dev libxrender-dev git wget gdebi xvfb \
    # Install wkhtml to pdf
    wkhtmltopdf \
    # Install pandoc
    pandoc \
    # Install latex
    # texlive-latex-base \
    # texlive-latex-recommended \
    # texlive-pictures \
    # texlive \
    texlive-fonts-recommended \
    texlive-plain-generic \
    texlive-latex-extra \
    texlive-xetex

RUN echo "xvfb-run -a -s \"-screen 0 640x480x16\" wkhtmltopdf \"\$@\"" >/usr/local/bin/wkhtmltopdf-wrapper && chmod +x /usr/local/bin/wkhtmltopdf-wrapper
WORKDIR /app
COPY config /app/config
COPY lib /app/lib
COPY mix.exs mix.lock /app/
COPY priv priv
COPY assets assets
COPY entrypoint.sh /app/

RUN mix local.hex --force && \
    mix local.rebar --force && \
    mix deps.get
RUN mix do compile

CMD ["bash", "/app/entrypoint.sh"]

the final image size may reduce a little more if I use mix release
so I’m settling with the above dockerfile setup
and I found this useful link while searching for a relevant solution, just posting it here for future reference
How to execute command from one docker container to another

Also Liked

al2o3cr

al2o3cr

I’m not following the logic at the end there: what’s the problem with a large image?

al2o3cr

al2o3cr

If you’re eventually deploying to k8s, you don’t want to start out using Docker-specific features like volume.

One approach that works cleanly across all deployment methods is to wrap a network service around the pandoc CLI: something that speaks your favorite network protocol (HTTP + JSON, gRPC, whatever) and accepts arguments + directions for where to put the output. Given that TeX can take a while, it probably needs to implement some kind of status tracking (“is my run of pandoc complete yet?”) or similar.

I’ve built something similar at a previous job. We needed to combine PDFs using a library only available on the JVM, so we wrote a small HTTP interface using Sinatra and JRuby (our team had a lot of folks who knew Ruby as well as Elixir). It accepted S3 URLs for the input PDFs and a webhook URL to notify when the output was available on S3.

Where Next?

Popular in Questions Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement