Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building the containers locally throws an error #20

Closed
groovytron opened this issue Oct 3, 2019 · 8 comments
Closed

Building the containers locally throws an error #20

groovytron opened this issue Oct 3, 2019 · 8 comments

Comments

@groovytron
Copy link
Contributor

groovytron commented Oct 3, 2019

The current behaviour

When we try to build the project's container, I get the following error cabal: Failed to build graphviz-2999.6.0.0. See the build log above for details..

Ouput of sudo make buildDockerImages:

cd nomnoml && make package
make[1]: Entering directory '/whatever/kroki/nomnoml'
docker build -f ops/docker/alpine/Dockerfile -t kroki-builder-nomnoml:alpine -t kroki-builder-nomnoml:latest -t kroki-builder-nomnoml:0.6.1-alpine .
Sending build context to Docker daemon  71.68kB

Step 1/9 : FROM node:10.15.0-alpine
 ---> 288d2f688643
Step 2/9 : RUN npm install -g pkg pkg-fetch
 ---> Using cache
 ---> 3c4c75c98283
Step 3/9 : ENV NODE node10
 ---> Using cache
 ---> 6a370b45d3ed
Step 4/9 : ENV PLATFORM alpine
 ---> Using cache
 ---> a4ee05cfb54a
Step 5/9 : ENV ARCH x64
 ---> Using cache
 ---> 7aa49102dfea
Step 6/9 : RUN /usr/local/bin/pkg-fetch ${NODE} ${PLATFORM} ${ARCH}
 ---> Using cache
 ---> 16a057199af7
Step 7/9 : COPY . /app
 ---> Using cache
 ---> 512be82b555b
Step 8/9 : WORKDIR /app
 ---> Using cache
 ---> 657c348dcaa2
Step 9/9 : RUN /usr/local/bin/pkg --targets ${NODE}-${PLATFORM}-${ARCH} . -o app.bin
 ---> Using cache
 ---> 40357553b986
Successfully built 40357553b986
Successfully tagged kroki-builder-nomnoml:alpine
Successfully tagged kroki-builder-nomnoml:latest
Successfully tagged kroki-builder-nomnoml:0.6.1-alpine
make[1]: Leaving directory '/whatever/kroki/nomnoml'
docker build -f server/ops/docker/build-static-erd -t kroki-builder-static-erd .
Sending build context to Docker daemon  36.72MB

Step 1/7 : FROM haskell:8
 ---> d0f33c86f706
Step 2/7 : RUN git clone https://github.com/BurntSushi/erd.git
 ---> Using cache
 ---> 23a26bf93de2
Step 3/7 : WORKDIR erd
 ---> Using cache
 ---> 6d47027f8d8f
Step 4/7 : RUN git checkout c443372d431a5020afa91989829352a2aa6b07cb
 ---> Using cache
 ---> d4e74e4d6bc3
Step 5/7 : RUN cabal update
 ---> Using cache
 ---> ef540b91b020
Step 6/7 : RUN cabal install --only-dependencies --force-reinstalls
 ---> Running in 93852ef0394e
Wrote tarball sdist to /erd/dist-newstyle/sdist/erd-0.1.3.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
 - containers-0.5.11.0 (lib) (requires download & build)
 - extensible-exceptions-0.1.1.4 (lib:extensible-exceptions) (requires download & build)
 - parallel-1.1.0.1 (lib:parallel) (requires download & build)
 - fgl-5.7.0.1 (lib) (requires download & build)
 - binary-0.8.7.0 (lib) (requires download & build)
 - text-1.2.4.0 (lib) (requires download & build)
 - polyparse-1.13 (lib) (requires download & build)
 - parsec-3.1.14.0 (lib) (requires download & build)
 - graphviz-2999.6.0.0 (lib:graphviz) (requires download & build)
Downloading  extensible-exceptions-0.1.1.4
Downloaded   extensible-exceptions-0.1.1.4
Downloading  containers-0.5.11.0
Starting     extensible-exceptions-0.1.1.4 (all, legacy fallback)
Downloaded   containers-0.5.11.0
Downloading  binary-0.8.7.0
Starting     containers-0.5.11.0 (lib)
Building     extensible-exceptions-0.1.1.4 (all, legacy fallback)
Downloaded   binary-0.8.7.0
Downloading  fgl-5.7.0.1
Installing   extensible-exceptions-0.1.1.4 (all, legacy fallback)
Building     containers-0.5.11.0 (lib)
Completed    extensible-exceptions-0.1.1.4 (all, legacy fallback)
Downloaded   fgl-5.7.0.1
Downloading  parallel-1.1.0.1
Downloaded   parallel-1.1.0.1
Downloading  text-1.2.4.0
Downloaded   text-1.2.4.0
Downloading  parsec-3.1.14.0
Downloaded   parsec-3.1.14.0
Downloading  polyparse-1.13
Downloaded   polyparse-1.13
Downloading  graphviz-2999.6.0.0
Downloaded   graphviz-2999.6.0.0
Installing   containers-0.5.11.0 (lib)
Completed    containers-0.5.11.0 (lib)
Starting     parallel-1.1.0.1 (all, legacy fallback)
Starting     fgl-5.7.0.1 (lib)
Starting     binary-0.8.7.0 (lib)
Building     parallel-1.1.0.1 (all, legacy fallback)
Building     fgl-5.7.0.1 (lib)
Building     binary-0.8.7.0 (lib)
Installing   parallel-1.1.0.1 (all, legacy fallback)
Completed    parallel-1.1.0.1 (all, legacy fallback)
Installing   fgl-5.7.0.1 (lib)
Completed    fgl-5.7.0.1 (lib)
Installing   binary-0.8.7.0 (lib)
Completed    binary-0.8.7.0 (lib)
Starting     text-1.2.4.0 (lib)
Building     text-1.2.4.0 (lib)
Installing   text-1.2.4.0 (lib)
Completed    text-1.2.4.0 (lib)
Starting     polyparse-1.13 (lib)
Starting     parsec-3.1.14.0 (lib)
Building     polyparse-1.13 (lib)
Building     parsec-3.1.14.0 (lib)
Installing   parsec-3.1.14.0 (lib)
Completed    parsec-3.1.14.0 (lib)
Installing   polyparse-1.13 (lib)
Completed    polyparse-1.13 (lib)
Starting     graphviz-2999.6.0.0 (all, legacy fallback)
Building     graphviz-2999.6.0.0 (all, legacy fallback)

Failed to build graphviz-2999.6.0.0.
Build log (
/root/.cabal/logs/ghc-8.8.1/graphviz-2999.6.0.0-c6eb5d98d43404431a1e831a5e372cc6643f0e2ed6c9f0444064337d13a6e254.log
):
Configuring graphviz-2999.6.0.0...
Warning: 'ghc-prof-options: -prof' is not necessary and will lead to problems
when used on a library. Use the configure flag --enable-library-profiling
and/or --enable-profiling.
Preprocessing library for graphviz-2999.6.0.0..
Building library for graphviz-2999.6.0.0..
[1 of 8] Compiling Data.GraphViz.Types.Internal ( Data/GraphViz/Types/Internal.hs, dist/build/Data/GraphViz/Types/Internal.o )
[2 of 8] Compiling Data.GraphViz.Types.Parsing ( Data/GraphViz/Types/Parsing.hs, dist/build/Data/GraphViz/Types/Parsing.o )

Data/GraphViz/Types/Parsing.hs:178:28: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘Char’
    Suppress this warning by saying ‘_ <- character '.'’
    |
178 |                 frac <- do character '.'
    |                            ^^^^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:188:25: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘Char’
    Suppress this warning by saying ‘_ <- character 'e'’
    |
188 |     where parseExp = do character 'e'
    |                         ^^^^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:268:21: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘String’
    Suppress this warning by saying ‘_ <- string fld’
    |
268 | parseField fld = do string fld
    |                     ^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:269:21: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘String’
    Suppress this warning by saying ‘_ <- whitespace'’
    |
269 |                     whitespace'
    |                     ^^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:270:21: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘Char’
    Suppress this warning by saying ‘_ <- character '='’
    |
270 |                     character '='
    |                     ^^^^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:271:21: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘String’
    Suppress this warning by saying ‘_ <- whitespace'’
    |
271 |                     whitespace'
    |                     ^^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:301:22: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘String’
    Suppress this warning by saying ‘_ <- whitespace'’
    |
301 |                      whitespace'
    |                      ^^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:302:22: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘Char’
    Suppress this warning by saying ‘_ <- parseComma’
    |
302 |                      parseComma
    |                      ^^^^^^^^^^

Data/GraphViz/Types/Parsing.hs:303:22: warning: [-Wunused-do-bind]
    A do-notation statement discarded a result of type ‘String’
    Suppress this warning by saying ‘_ <- whitespace'’
    |
303 |                      whitespace'
    |                      ^^^^^^^^^^^
[3 of 8] Compiling Data.GraphViz.Types.Printing ( Data/GraphViz/Types/Printing.hs, dist/build/Data/GraphViz/Types/Printing.o )

Data/GraphViz/Types/Printing.hs:152:16: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at Data/GraphViz/Types/Printing.hs:38:8-35
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.<>’,
              imported from ‘Text.PrettyPrint’ at Data/GraphViz/Types/Printing.hs:(51,1)-(58,32)
              (and originally defined in ‘Text.PrettyPrint.HughesPJ’)
    |
152 | wrap b a d = b <> d <> a
    |                ^^

Data/GraphViz/Types/Printing.hs:152:21: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at Data/GraphViz/Types/Printing.hs:38:8-35
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.<>’,
              imported from ‘Text.PrettyPrint’ at Data/GraphViz/Types/Printing.hs:(51,1)-(58,32)
              (and originally defined in ‘Text.PrettyPrint.HughesPJ’)
    |
152 | wrap b a d = b <> d <> a
    |                     ^^

Data/GraphViz/Types/Printing.hs:155:26: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at Data/GraphViz/Types/Printing.hs:38:8-35
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.<>’,
              imported from ‘Text.PrettyPrint’ at Data/GraphViz/Types/Printing.hs:(51,1)-(58,32)
              (and originally defined in ‘Text.PrettyPrint.HughesPJ’)
    |
155 | commaDel a b = unqtDot a <> comma <> unqtDot b
    |                          ^^

Data/GraphViz/Types/Printing.hs:155:35: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at Data/GraphViz/Types/Printing.hs:38:8-35
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.<>’,
              imported from ‘Text.PrettyPrint’ at Data/GraphViz/Types/Printing.hs:(51,1)-(58,32)
              (and originally defined in ‘Text.PrettyPrint.HughesPJ’)
    |
155 | commaDel a b = unqtDot a <> comma <> unqtDot b
    |                                   ^^

Data/GraphViz/Types/Printing.hs:158:25: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at Data/GraphViz/Types/Printing.hs:38:8-35
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.<>’,
              imported from ‘Text.PrettyPrint’ at Data/GraphViz/Types/Printing.hs:(51,1)-(58,32)
              (and originally defined in ‘Text.PrettyPrint.HughesPJ’)
    |
158 | printField f v = text f <> equals <> toDot v
    |                         ^^

Data/GraphViz/Types/Printing.hs:158:35: error:
    Ambiguous occurrence ‘<>’
    It could refer to
       either ‘Prelude.<>’,
              imported from ‘Prelude’ at Data/GraphViz/Types/Printing.hs:38:8-35
              (and originally defined in ‘GHC.Base’)
           or ‘Text.PrettyPrint.<>’,
              imported from ‘Text.PrettyPrint’ at Data/GraphViz/Types/Printing.hs:(51,1)-(58,32)
              (and originally defined in ‘Text.PrettyPrint.HughesPJ’)
    |
158 | printField f v = text f <> equals <> toDot v
    |                                   ^^
cabal: Failed to build graphviz-2999.6.0.0. See the build log above for
details.

Expected behaviour

The containers images should be built without any issue

Way to reproduce the error

  1. git clone the repository
  2. Run sudo make buildDockerImages

Thanks in advance for your help.

@groovytron
Copy link
Contributor Author

It might not be relevant be is there any reason the containers need to be built with sudo?
Thanks for your answer.

@ggrossetie
Copy link
Member

Could you please share your host system? I you are using a Linux system, the following command should give enough information:

$ cat /etc/*release*

In the past, I had some issues to build a statically linked binary of erd: BurntSushi/erd#40 but since then the project can now be built using stack (so I might need to update the build).

It might not be relevant be is there any reason the containers need to be built with sudo?

We are using sudo because I believe it's required by docker (but I might be wrong). Did you try to run the command without sudo?

@groovytron
Copy link
Contributor Author

groovytron commented Oct 4, 2019

Of course no problem. Here is my host system information:

$ cat /etc/*release*
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="0;36"
HOME_URL="https://www.archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux

In the past, I had some issues to build a statically linked binary of erd: BurntSushi/erd#40 but since then the project can now be built using stack (so I might need to update the build).

From what I read in the comments, it looks like you are not far away from the solution. I am not familiar with Haskell but I will see if I can help you in that (my job makes me really busy lately ^^').

We are using sudo because I believe it's required by docker (but I might be wrong). Did you try to run the command without sudo?

I can run it on my own machine without sudo. I configured my docker following the ArchWiki so I just needed to add myself to the docker group to be able to use docker without sudo. Looks like you can do the same for Ubuntu now.

So I think it might be true in the past but I don't think it's needed anymore nowadays. It looks like most distributions rather encourage you to add yourself in the docker group instead of sudo. But it's just a tiny small detail and I'm pretty sure it's not related to this issue. 😅

@ggrossetie
Copy link
Member

Of course no problem. Here is my host system information:

I don't really know why but it's running fine on an Ubuntu host. It looks like another issue with Docker on an Arch Linux host.
I'm wondering what are the root causes... but one thing is sure it's really annoying! I mean the whole point of Docker is to provide an abstraction so it works on any host but I guess that's not true 😞

From what I read in the comments, it looks like you are not far away from the solution. I am not familiar with Haskell but I will see if I can help you in that (my job makes me really busy lately ^^').

I'm not familiar with Haskell either but thankfully the Haskell community provides some good help 😉

I can run it on my own machine without sudo. I configured my docker following the ArchWiki so I just needed to add myself to the docker group to be able to use docker without sudo. Looks like you can do the same for Ubuntu now.

You are absolutely right. I might add a note on the README to state that sudo is not necessarily mandatory.

I've created a branch where I'm using an Ubuntu base image with stack to build a statically linked binary of erd.
Could you please checkout this branch build-static-erd-stack and run:

$ docker build -f server/ops/docker/build-static-erd -t kroki-builder-static-erd .

Thanks for your help 👍

@groovytron
Copy link
Contributor Author

groovytron commented Oct 4, 2019

I don't really know why but it's running fine on an Ubuntu host. It looks like another issue with Docker on an Arch Linux host.
I'm wondering what are the root causes... but one thing is sure it's really annoying! I mean the whole point of Docker is to provide an abstraction so it works on any host but I guess that's not true disappointed

I think this problem reported in this issue comes from the fact that the mermaid container uses puppeteer. As puppeteer uses Chrome under the hood, it needs specific configuration to make it run indide a container (or do privilege escalation and run the container with sudo which is not secure). They talk about it in their documentation.

So I guess docker works pretty well in most cases for environment sharing but it gets a bit trickier when it comes to use a complete browser inside a container. But I'm sure we can find the root cause and make these containers more portable. 😅

But I don't think the problem is the same as the one in the erd container.

I'll try to test your branch and give you a feedback this weekend. 👍

@ggrossetie
Copy link
Member

I think this problem reported in this issue comes from the fact that the mermaid container uses puppeteer. As puppeteer uses Chrome under the hood, it needs specific configuration to make it run indide a container (or do privilege escalation and run the container with sudo which is not secure). They talk about it in their documentation.

It was somehow related to Puppeteer because upgrading Puppeteer to the latest version fixed this issue.
But once a Docker image is built it should run on any host. On the Puppeteer documentation, they describe how to build a Docker image with an headless Chrome but then docker run should work the same on an Ubuntu host or an ArchLinux host.

But I don't think the problem is the same as the one in the erd container.

Indeed, in this case the error happens during docker build which might depend on the host... even though we execute commands inside the container from a base image. So in theory it should be portable and we should have the same behavior on an Ubuntu host or ArchLinux host.

I'll try to test your branch and give you a feedback this weekend.

Awesome, thanks!

@groovytron
Copy link
Contributor Author

groovytron commented Oct 7, 2019

It looks like the build for this container worked on the build-static-erd-stack branch. Here is the log file from the build:

out-erd.log

Sorry for the delay. 😅

@ggrossetie
Copy link
Member

Thanks for your input!
I've submitted a pull request: #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants