[英]Minimal haskell (ghc) program installation (deployment without ghc/cabal)
(My problem is about distribute binaries without haskell-platform, ghc, cabal, ...) (我的问题是关于没有haskell-platform,ghc,cabal等的分发二进制文件)
I need deploy a well cabal formed haskell application (a Yesod scaffolded) but I have disk space restrictions. 我需要部署一个良好的cabal形成haskell应用程序(一个Yesod脚手架),但我有磁盘空间限制。
GHC size is about 1Gbytes, store all cabal source code, packages, etc... require more disk space, etc... GHC大小约为1Gbytes,存储所有cabal源代码,包等...需要更多磁盘空间等...
Obviously, haskell-platform, ghc, ... is about development (not deployment). 显然,haskell-platform,ghc,...是关于开发(不是部署)。
In my specific case I can generate 在我的具体情况下,我可以生成
cabal clean && cabal configure && cabal build
and run succesfully (some like) 并成功运行(有些像)
./dist/build/MyEntryPoint/MyEntryPoint arg arg arg
But, what about dependencies?, how move it to production environment? 但是,依赖关系呢?如何将其转移到生产环境? (together my "dist" compilation)
(连同我的“dist”汇编)
Can I put binary dependencies without cabal? 我可以在没有cabal的情况下放置二进制依赖项 How?
怎么样?
Thank you very much! 非常感谢你!
By default, ghc uses static linking of the Haskell libraries. 默认情况下,ghc使用Haskell库的静态链接。 So the resulting binary is independent of the Haskell ecosystem.
因此,生成的二进制文件独立于Haskell生态系统。 If your program does not need any data files, just copy the binary out from
./dist/build/MyEntryPoint/MyEntryPoint
to the host 如果您的程序不需要任何数据文件,只需将二进制文件从
./dist/build/MyEntryPoint/MyEntryPoint
复制到主机
If you also have data files (eg templates, images, static html pages) that are referenced by the binary using the data path finding logic of Cabal, you can use Setup copy
as follows (using happy as an example): 如果您还有使用Cabal的数据路径查找逻辑的二进制文件引用的数据文件(例如模板,图像,静态html页面),则可以按如下方式使用
Setup copy
(使用happy作为示例):
/tmp/happy-1.18.10 $ ./Setup configure Warning: defaultUserHooks in Setup script is deprecated. Configuring happy-1.18.10... /tmp/happy-1.18.10 $ ./Setup build Building happy-1.18.10... Preprocessing executable 'happy' for happy-1.18.10... [ 1 of 18] Compiling NameSet ( src/NameSet.hs, dist/build/happy/happy-tmp/NameSet.o ) [..] [18 of 18] Compiling Main ( src/Main.lhs, dist/build/happy/happy-tmp/Main.o ) Linking dist/build/happy/happy ... /tmp/happy-1.18.10 $ ./Setup copy --destdir=/tmp/to_be_deployed/ Installing executable(s) in /tmp/to_be_deployed/usr/local/bin /tmp/happy-1.18.10 $ find /tmp/to_be_deployed /tmp/to_be_deployed /tmp/to_be_deployed/usr /tmp/to_be_deployed/usr/local /tmp/to_be_deployed/usr/local/bin /tmp/to_be_deployed/usr/local/bin/happy /tmp/to_be_deployed/usr/local/share /tmp/to_be_deployed/usr/local/share/doc /tmp/to_be_deployed/usr/local/share/doc/happy-1.18.10 /tmp/to_be_deployed/usr/local/share/doc/happy-1.18.10/LICENSE /tmp/to_be_deployed/usr/local/share/happy-1.18.10 /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Lib-ghc-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Lib-ghc /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Lib /tmp/to_be_deployed/usr/local/share/happy-1.18.10/GLR_Base /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-coerce-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-ghc-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-debug /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-coerce /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays-ghc /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-arrays /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-coerce /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate-ghc /tmp/to_be_deployed/usr/local/share/happy-1.18.10/HappyTemplate /tmp/happy-1.18.10 $ rsync -rva /tmp/to_be_deployed/ production.host:/ [..]
If you do not want to install into /usr/local
then pass the desired prefix to Setup configure
. 如果您不想安装到
/usr/local
则将所需的前缀传递给Setup configure
。
This works well if the target host is otherwise similar (same versions of C libraries such as gmp and ffi installed). 如果目标主机在其他方面类似(相同版本的C库,如安装了gmp和ffi),则此方法很有效。 If you also need to statically link some C library, see the question that hammar has linked in his comment.
如果您还需要静态链接某个C库,请参阅hammar在其评论中链接的问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.