commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.99k stars 844 forks source link

Docker build with stack fails with 137 on Mac M1 Chipset #5880

Open sbilgil opened 2 years ago

sbilgil commented 2 years ago

I have downloaded facebook/duckling. I run docker build. It failed with code: executor failed running [/bin/sh -c stack setup -j1]: exit code: 137

Steps to reproduce

For example:

  1. clone facebook/duckling
  2. run docker build

Expected

build succesfully

Actual

executor failed running [/bin/sh -c stack setup -j1]: exit code: 137

Dockerfile

`FROM --platform=linux/amd64 haskell:latest AS builder

RUN apt-get update -qq && \ apt-get install -qq -y libpcre3 libpcre3-dev build-essential pkg-config --fix-missing --no-install-recommends && \ apt-get clean && \ rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/*

RUN mkdir /log

WORKDIR /duckling

RUN chmod -R 777 /duckling

ADD . .

ENV LANG=C.UTF-8 RUN stack --version RUN stack setup -j1

ADD . .

RUN stack install

FROM --platform=linux/amd64 alpine:latest ENV LANG C.UTF-8 RUN apk add --no-cache libc6-compat RUN apk update -qq && \ apk add -qq libpcre32 pcre pcre-dev pcre-tools && \ apk add --no-cache gmp-dev && \ apk add --virtual build-dependencies && \ apk add --no-cache build-base gcc && \ apk add g++ && \ apk add pcre-dev && \ ln -s /usr/lib/libpcre.so /usr/lib/libpcre.so.3 && \ rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/* RUN apk add gcompat RUN apk add tzdata

COPY --from=builder /root/.local/bin/duckling-example-exe /usr/local/bin/

EXPOSE 8000

CMD ["duckling-example-exe", "-p", "8000"]

`

mpilgrem commented 2 years ago

@sbilgil thanks for reporting. Can you help me understand what appears to be happening? The Docker file starts with a reference to Linux/AMD64 (Linux/x86_64) but you refer to Mac M1, which I understand is Apple silicon/ARM-based. Does that mean that Apple's Rosetta is being called upon to translate a x86_64 executable into something that runs on Apple silicon?

If you specify Stack's verbose output (stack --verbose setup -j1) does that provide some insight as to when the problem arises?

sbilgil commented 2 years ago

Actually i am trying to build duckling on alpine linux distro. When i prepare my dockerfile on windows or intel mac it works fine. But when i use my M1 chip mac same dockerfile cant work. I googled it and they offer to add platform parameter to it. This image will work on linux machines.

And when i use verbose and tried to create image. i got these logs:

20 288.4 2022-09-26 06:41:47.134380: [info] Processed 162400 cabal files

20 288.8 2022-09-26 06:41:47.572399: [info] Processed 162800 cabal files

20 289.3 2022-09-26 06:41:48.083539: [info] Processed 163200 cabal files

20 289.8 2022-09-26 06:41:48.564819: [info] Processed 163600 cabal files

20 290.3 2022-09-26 06:41:49.119545: [info] Package index cache populated

20 290.5 2022-09-26 06:41:49.287867: [debug] Added in cabal file hash: regex-posix-clib-2.7@sha256:998fca06da3d719818f0691ef0b8b9b7375afeea228cb08bd9e2db53f96b0cd7,1232

20 290.5 2022-09-26 06:41:49.294333: [debug] Got blob from Pantry database for regex-posix-clib-2.7@sha256:998fca06da3d719818f0691ef0b8b9b7375afeea228cb08bd9e2db53f96b0cd7,1232

20 290.6 2022-09-26 06:41:49.307738: [debug] Downloading archive from https://hackage.haskell.org/package/regex-posix-clib-2.7.tar.gz

20 292.5 2022-09-26 06:41:51.300355: [debug] Completing package location information from dependent-sum-0.7.1.0@sha256:0e419237f5b86da3659772afff9cab355c0f8d5b3fdb15a5b30e673d8dc83941,2147

20 292.5 2022-09-26 06:41:51.301759: [debug] Got blob from Pantry database for dependent-sum-0.7.1.0@sha256:0e419237f5b86da3659772afff9cab355c0f8d5b3fdb15a5b30e673d8dc83941,2147

20 292.5 2022-09-26 06:41:51.304167: [debug] Downloading archive from https://hackage.haskell.org/package/dependent-sum-0.7.1.0.tar.gz

20 293.2 2022-09-26 06:41:51.984971: [debug] Completing package location information from constraints-extras-0.3.1.0@sha256:c70fcf437e1d640cfd50a8eda1db47a64e49c96857e08fd0d8c438327d908ac1,1846

20 293.2 2022-09-26 06:41:51.986001: [debug] Got blob from Pantry database for constraints-extras-0.3.1.0@sha256:c70fcf437e1d640cfd50a8eda1db47a64e49c96857e08fd0d8c438327d908ac1,1846

20 293.2 2022-09-26 06:41:51.988777: [debug] Downloading archive from https://hackage.haskell.org/package/constraints-extras-0.3.1.0.tar.gz

20 293.8 2022-09-26 06:41:52.556776: [debug] Parsing cabal file for regex-posix (from Hackage)

20 293.8 2022-09-26 06:41:52.557740: [debug] Got blob from Pantry database for regex-posix-0.96.0.0@sha256:690d1366e9ea6df71ded3daf49ca3d53c63eda3f95937962299b2391824dc3b3,2531

20 293.8 2022-09-26 06:41:52.596433: [debug] Migration executed: CREATE TABLE "config_cache"("id" INTEGER PRIMARY KEY,"directory" VARCHAR NOT NULL DEFAULT (hex(randomblob(16))),"type" VARCHAR NOT NULL,"pkg_src" VARCHAR NOT NULL,"active" BOOLEAN NOT NULL,"path_env_var" VARCHAR NOT NULL,"haddock" BOOLEAN NOT NULL DEFAULT 0,CONSTRAINT "unique_config_cache" UNIQUE ("directory","type"))

20 293.8 2022-09-26 06:41:52.596671: [debug] Migration executed: CREATE TABLE "config_cache_dir_option"("id" INTEGER PRIMARY KEY,"config_cache_id" INTEGER NOT NULL REFERENCES "config_cache" ON DELETE CASCADE ON UPDATE RESTRICT,"index" INTEGER NOT NULL,"option" VARCHAR NOT NULL,CONSTRAINT "unique_config_cache_dir_option" UNIQUE ("config_cache_id","index"))

20 293.8 2022-09-26 06:41:52.596794: [debug] Migration executed: CREATE TABLE "config_cache_no_dir_option"("id" INTEGER PRIMARY KEY,"config_cache_id" INTEGER NOT NULL REFERENCES "config_cache" ON DELETE CASCADE ON UPDATE RESTRICT,"index" INTEGER NOT NULL,"option" VARCHAR NOT NULL,CONSTRAINT "unique_config_cache_no_dir_option" UNIQUE ("config_cache_id","index"))

20 293.8 2022-09-26 06:41:52.596938: [debug] Migration executed: CREATE TABLE "config_cache_dep"("id" INTEGER PRIMARY KEY,"config_cache_id" INTEGER NOT NULL REFERENCES "config_cache" ON DELETE CASCADE ON UPDATE RESTRICT,"ghc_pkg_id" VARCHAR NOT NULL,CONSTRAINT "unique_config_cache_dep" UNIQUE ("config_cache_id","ghc_pkg_id"))

20 293.8 2022-09-26 06:41:52.597255: [debug] Migration executed: CREATE TABLE "config_cache_component"("id" INTEGER PRIMARY KEY,"config_cache_id" INTEGER NOT NULL REFERENCES "config_cache" ON DELETE CASCADE ON UPDATE RESTRICT,"component" BLOB NOT NULL,CONSTRAINT "unique_config_cache_component" UNIQUE ("config_cache_id","component"))

20 293.8 2022-09-26 06:41:52.599740: [debug] Asking for a supported GHC version

20 293.8 2022-09-26 06:41:52.600188: [debug] Getting system compiler version

20 293.8 2022-09-26 06:41:52.617796: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/opt/ghc/9.4.2/bin/ghc-9.4.2"]

20 293.8 2022-09-26 06:41:52.619564: [debug] Looking for executable(s): ["/opt/ghc/9.4.2/bin/ghc-pkg-9.4.2","/opt/ghc/9.4.2/bin/ghc-pkg"]

20 293.8 2022-09-26 06:41:52.620264: [debug] Looking for executable(s): ["/opt/ghc/9.4.2/bin/runghc-9.4.2","/opt/ghc/9.4.2/bin/runghc"]

20 293.8 2022-09-26 06:41:52.620647: [debug] Looking for executable(s): ["/opt/ghc/9.4.2/bin/haddock-9.4.2","/opt/ghc/9.4.2/bin/haddock-ghc-9.4.2","/opt/ghc/9.4.2/bin/haddock","/opt/ghc/9.4.2/bin/haddock-ghc"]

20 293.8 2022-09-26 06:41:52.622260: [debug] Run process: /opt/ghc/9.4.2/bin/ghc-9.4.2 --info

20 308.3 Killed

worm2fed commented 1 year ago

same problem with haskell:9.0.2-slim