问题描述
我有一台服务器,想在不安装 GHC 和 Cabal 的情况下部署我的 Yesod 应用程序.我不确定是否可行:一位老师告诉我,我必须首先在我的机器上编译 Keter,然后将 keter
可执行文件放在服务器上,尽管我不知道该怎么做.
I have a server and want to deploy my Yesod applications without installing GHC and Cabal. I am not sure if is possible: a Teacher told me that I must first compile Keter in my machine and, after that, put keter
executable on the server, though I am not sure how to do that.
推荐答案
要构建 Keter,首先您需要从其 GitHub 存储库.然后你需要设置一个 Haskell 构建环境并使用 cabal build
或 cabal install
来构建源代码.就个人而言,我使用从基于以下 Dockerfile
的图像派生的 Docker 容器:
To build Keter, first you'll need to clone the sources from its GitHub repository. Then you'll need to set up a Haskell build environment and use cabal build
or cabal install
to build the sources. Personally, I use a Docker container derived from an image based on the following Dockerfile
:
FROM haskell:7.10.2
RUN apt-get update && apt-get install -y \
git
RUN mkdir /src
RUN cd src && \
git clone https://github.com/snoyberg/keter && \
cd keter && \
git checkout e8b5a3fd5e14dfca466f8acff2a02f0415fceeb0
WORKDIR /src/keter
RUN cabal update
RUN cabal install keter
ENTRYPOINT /bin/bash
这是一张包含在特定修订版中检出的 Keter 源的图像,其中包含构建所有这些所需的最低 GHC 工具链.cabal
命令行拉下项目的所有依赖项并编译整个项目.完成后,您可以从 ~/.cabal/bin/keter
获取 keter
可执行文件.
This is an image containing the Keter sources checked out at a specific revision with the minimum GHC toolchain required to build it all. The cabal
command lines pull down all the project's dependencies and compiles the whole thing. Once this has completed, you can grab the keter
executable from ~/.cabal/bin/keter
.
即使您选择不使用 Docker,这个文件也应该让您大致了解如何设置您的环境.
Even if you choose not to use Docker, this file should give you a rough idea how to set up your environment.
现在您已经编译了 Keter,您可以在另一个 Docker 容器中运行它.以下是对应图像的 Dockerfile
大概是什么样子的:
Now you have Keter compiled, you can run it inside another Docker container. Here's a rough idea what the Dockerfile
for the corresponding image might look like:
FROM debian
RUN apt-get update && apt-get install -y \
libgmp-dev \
nano \
postgresql
COPY keter /opt/keter/bin/
COPY keter-config.yaml /opt/keter/etc/
EXPOSE 80
CMD ["/opt/keter/bin/keter", "/opt/keter/etc/keter-config.yaml"]
这将采用基本的 Debian 映像并在其上安装最少的一组软件包.然后将 keter
可执行文件和配置文件复制到映像中.如果您随后从生成的映像运行容器,它将启动 keter
可执行文件.
Ths will take a base Debian image and install a minimal set of packages on top of it. It then copies the keter
executable and configuration file into the image. If you then run a container from the resulting image it will start the keter
executable.
公平警告:整个过程相当复杂.我仍在努力调整自己的确切细节.祝你好运!
Fair warning: This whole process is fairly involved. I'm still working on tweaking the exact details myself. Good luck!
这篇关于在没有 GHC 和阴谋集团的情况下运行 Keter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!