December 02, 2021

I am trying to create a Docker image where I can build my dub project. Here is a simple Dockerfile.

FROM ubuntu as build

RUN apt-get update \
    && apt-get install --no-install-recommends -y -q locales build-essential apt-transport-https ca-certificates dub\
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /compiling
COPY source source
COPY dub.json .

RUN dub build -b release

When I try to run docker build ., I get the following output:

[+] Building 1.0s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 424B                                                                                                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest                                                                                                                                                                                                         0.6s
 => [internal] load build context                                                                                                                                                                                                                                        0.0s
 => => transferring context: 2.41kB                                                                                                                                                                                                                                      0.0s
 => [1/6] FROM docker.io/library/ubuntu@sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322                                                                                                                                                          0.0s
 => CACHED [2/6] RUN apt-get update     && apt-get install --no-install-recommends -y -q locales build-essential apt-transport-https ca-certificates dub    && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*                                        0.0s
 => CACHED [3/6] WORKDIR /compiling                                                                                                                                                                                                                                      0.0s
 => CACHED [4/6] COPY source source                                                                                                                                                                                                                                      0.0s
 => CACHED [5/6] COPY dub.json .                                                                                                                                                                                                                                         0.0s
 => ERROR [6/6] RUN dub build -b release                                                                                                                                                                                                                                 0.2s
------
 > [6/6] RUN dub build -b release:
#10 0.208 dub: symbol lookup error: dub: undefined symbol: _D3std3net4curl4HTTP9__mixin376onSendMFNdDFAvZmZv

I am running this from M1 MacBook but was successfully using similar Dockerfile with dub on a Linux machine. Could it be the issue?

December 02, 2021

The first thing i'd check:

  • make sure you have curl installed on your docker image
  • make sure you link with the curl library (since you are using dub)

That's on the notes: https://dlang.org/phobos/std_net_curl.html