6

I am attempting to wrap a Raku based web app in a dockerfile. I am using the Cro web framework but I cannot seem to install the Cro successfully.

I tried the dockerfile below:

# Use the official Rakudo Star image
FROM rakudo-star:latest

RUN apt update && \
    apt upgrade -y && \
    apt install zip -y && \
    apt install build-essential -y && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory inside the container
WORKDIR /app

# Copy your project files into the container
COPY ./bin /app/bin
COPY ./config /app/config
COPY ./lib /app/lib
COPY ./t /app/t
COPY ./META6.json /app
COPY ./www /app/www

RUN zef upgrade zef

# install dependencies not in raku.land
RUN git clone https://github.com/JuneKelly/perl6-config-clever && \
    cd perl6-config-clever && \
    zef install .

RUN git clone https://github.com/skinkade/crypt-random && \
    cd crypt-random  && \
    zef install .

# Install project dependencies
RUN zef install --verbose --force --/test Array::Circular
RUN zef install --verbose --force --/test Docker::File
RUN zef install --verbose --force --/test File::Ignore
RUN zef install --verbose --force --/test IO::Socket::Async::SSL
RUN zef install --verbose --force --/test Digest::SHA1::Native
RUN zef install --debug --/test cro
RUN zef install --verbose --force --/test --deps-only .

# Expose any necessary ports (optional)
# EXPOSE 8080

# Set the default command to run your Raku application
CMD ["raku", "/app/bin/app"]

I am expecting it to build, but I get errors like below:

 > [18/20] RUN zef install --verbose --force --/test Cro::HTTP:
2.966 ===> Searching for: Cro::HTTP
37.74 Use of uninitialized value of type IO::Path in string context.
37.74 Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
82.97 Use of uninitialized value of type IO::Path in string context.
82.97 Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
82.97 Use of uninitialized value of type IO::Path in string context.
82.97 Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
82.97 Use of uninitialized value of type IO::Path in string context.
82.97 Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
82.97   in block  at /usr/share/perl6/site/sources/CD3A622C2C09A8A47FE369BE7FE1F5CB7001C1B1 (Zef::Client) line 563
82.97   in block  at /usr/share/perl6/site/sources/CD3A622C2C09A8A47FE369BE7FE1F5CB7001C1B1 (Zef::Client) line 563
82.97   in block  at /usr/share/perl6/site/sources/CD3A622C2C09A8A47FE369BE7FE1F5CB7001C1B1 (Zef::Client) line 563
82.97   in block  at /usr/share/perl6/site/sources/CD3A622C2C09A8A47FE369BE7FE1F5CB7001C1B1 (Zef::Client) line 563
82.97 Use of uninitialized value of type IO::Path in string context.
82.97 Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
<SNIPPED>
Dockerfile:38
--------------------
  36 |     RUN zef install --verbose --force --/test IO::Socket::Async::SSL
  37 |     RUN zef install --verbose --force --/test Digest::SHA1::Native
  38 | >>> RUN zef install --verbose --force --/test Cro::HTTP
  39 |     RUN zef install --debug --/test cro
  40 |     RUN zef install --verbose --force --/test --deps-only .
--------------------
ERROR: failed to solve: process "/bin/sh -c zef install --verbose --force --/test Cro::HTTP" did not complete successfully: exit code: 1

Any ideas? As you can see I have already been trying a few hacks :(

0

2 Answers 2

5

if you rootle around in the error messages, the first failure says:

25.00 Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory
25.00 at /app/site#sources/EECBFFAFE1EB0CDBF5E9BEFF953D441C3690042E (Cro::TLS):9

to fix that add in libssl-dev somewhere up above, like this:

RUN apt update && \
  5     apt upgrade -y && \
  6     apt install zip -y && \
  7     apt install build-essential -y && \
  8     apt install -y libssl-dev && \
  9     rm -rf /var/lib/apt/lists/*

I have not tried to get your webapp running since I do not know what it is so my build fails at the zef install . point - if you still have trouble, I suspect that https://github.com/JuneKelly/perl6-config-clever may be somewhat stale as it was last updated 9 years ago and was not moved to the zef repo

Sign up to request clarification or add additional context in comments.

Comments

3

Many thanks for all the comments and answers, they did help! I got it working. I did have to go through the dependencies and make sure they worked, hence the monstrosity below. This Dockerfile is based on trial and error and also parts of various Dockerfiles I found online, including the official (but old) Cro docker images.

I think there are a few issues behind the problems:

  • Name space problems in Raku with the Digest lib. I had to poke around and find the updated lib that fixed this.
  • Some unspecified issue with zef that seems to cause it to fail intermittently when running in an Ubuntu docker image. I could not get zef to run all the installs as one command, I had to do it in single RUN commands to get it to work. Puzzling. It makes the resulting docker image very big so I will probably pull these commands into a bash script and run that.
  • Some libs do not want to install from the default repo (raku.land?) so I had to pull these directly from GitHub.

It needs more work, but it does start the webapp. I have more issues, but not docker :)

FROM rakudo-star:latest

RUN apt update && \
    apt upgrade -y && \
    apt install -y curl uuid-dev libpq-dev libssl-dev unzip build-essential zip libxml2-dev && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory inside the container
WORKDIR /app

# Copy your project files into the container
COPY ./bin /app/bin

COPY ./config /app/config
COPY ./lib /app/lib
COPY ./t /app/t
COPY ./META6.json /app
COPY ./www /app/www

RUN git clone https://github.com/ugexe/zef.git /tmp/zef && \
    cd /tmp/zef && \
    raku -I. bin/zef install . --/test

# install dependencies not in raku.land or that cause issues
RUN git clone https://github.com/JuneKelly/perl6-config-clever && \
    cd perl6-config-clever && \
    zef install .

RUN git clone https://github.com/skinkade/crypt-random && \
    cd crypt-random  && \
    zef install .

RUN git clone https://github.com/JJ/Raku-Digest-HMAC.git && \
    cd Raku-Digest-HMAC && \
    zef install .

RUN git clone https://github.com/retupmoca/p6-markdown.git && \
    cd p6-markdown && \
    zef install .

# Install project dependencies
RUN zef install --verbose --force --/test Array::Circular
RUN zef install --verbose --force --/test Docker::File
RUN zef install --verbose --force --/test File::Ignore
RUN zef install --verbose --force --/test IO::Socket::Async::SSL
RUN zef install --verbose --force --/test Digest::SHA1::Native
RUN zef install --verbose --force --/test JSON::Unmarshal
RUN zef install --verbose --force --/test JSON::Fast
RUN zef install --verbose --force --/test OO::Monitors
RUN zef install --verbose --force --/test Shell::Command
RUN zef install --verbose --force --/test DBIish::Pool
RUN zef install --verbose --force --/test JSON::JWT
RUN zef install --verbose --force --/test TinyFloats
RUN zef install --verbose --force --/test CBOR::Simple
RUN zef install --verbose --force --/test Log::Timeline
RUN zef install --verbose --force --/test Text::Markdown
RUN zef install --verbose --force --/test Terminal::ANSIColor
RUN zef install --verbose --force --/test Base64
RUN zef install --verbose --force --/test IO::Socket::SSL
RUN zef install --verbose --force --/test IO::Path::ChildSecure
RUN zef install --verbose --force --/test JSON::JWT
RUN zef install --verbose --force --/test HTTP::HPACK
RUN zef install --verbose --force --/test Cro::Core
RUN zef install --verbose --force --/test Cro::TLS
RUN zef install --verbose --force --/test https://github.com/croservices/cro-http.git
RUN zef install --verbose --force --/test App::Prove6
RUN zef install --verbose --force --/test Env::Dotenv
RUN zef install --verbose --force --/test HTTP::Tinyish
RUN zef install --verbose --force --/test JSON::Fast
RUN zef install --verbose --force --/test Logger
RUN zef install --verbose --force --/test UUID::V4
RUN zef install --verbose --force --/test W3C::DOM
RUN zef install --verbose --force --/test Method::Also

RUN git clone https://github.com/libxml-raku/LibXML-raku.git && \
    cd LibXML-raku && \
    zef install .

EXPOSE 10000

CMD ["raku", "/app/bin/app"]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.