-
Notifications
You must be signed in to change notification settings - Fork 3
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
[35] - packaging #77
base: main
Are you sure you want to change the base?
[35] - packaging #77
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辛苦酌情采纳
@@ -1,106 +1,109 @@ | |||
--- | |||
redirect_from: "server/guides/packaging" | |||
layout: page | |||
title: Packaging Applications for Deployment | |||
title: 将应用程序打包以供部署 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
打包应用程序以供部署
--- | ||
|
||
Once an application is built for production, it still needs to be packaged before it can be deployed to servers. There are several strategies for packaging Swift applications for deployment. | ||
一旦应用程序为生产环境构建完成,它仍然需要打包才能部署到服务器上。有几种策略可以用于打包 Swift 应用程序以进行部署。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
打包 Swift 应用程序以进行部署有多种策略。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一旦应用程序构建用于生产
|
||
Since distroless supports Docker and is based on Debian, packaging a Swift application on it is fairly similar to the Docker process above. Here is an example `Dockerfile` that builds and packages the application on top of a distroless's C++ base image: | ||
由于 distroless 支持 Docker 并基于 Debian,在其上打包 Swift 应用程序与上述 Docker 过程非常相似。下面是一个在 distroless 的 C++ 基础镜像上构建和打包应用程序的 `Dockerfile` 示例: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
将 Swift 应用程序打包到其中的过程与上述 Docker 过程十分相似
CMD ["<executable-name>"] | ||
``` | ||
|
||
Note the above uses `gcr.io/distroless/cc-debian10` as the runtime image which should work for Swift programs that do not use `FoundationNetworking` or `FoundationXML`. In order to provide more complete support we (the community) could put in a PR into distroless to introduce a base image for Swift that includes `libcurl` and `libxml` which are required for `FoundationNetworking` and `FoundationXML` respectively. | ||
注意,上述使用 `gcr.io/distroless/cc-debian10` 作为运行时镜像,这对于不使用 `FoundationNetworking` 或 `FoundationXML` 的 Swift 程序应该有效。为了提供更完整的支持,我们(社区)可以向 distroless 提交 PR,引入一个包含 `libcurl` 和 `libxml` 的 Swift 基础镜像,分别用于 `FoundationNetworking` 和 `FoundationXML`。 | ||
|
||
|
||
## Archive (Tarball, ZIP file, etc.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Archive 有没有必要翻译一下
@@ -110,9 +113,10 @@ $ docker run --rm \ | |||
/bin/bash -cl "swift build -c release --static-swift-stdlib" | |||
``` | |||
|
|||
Note we are bind mounting the source directory so that the build writes the build artifacts to the local drive from which we will package them later. | |||
注意,我们正在绑定挂载源目录,以便构建将构建工件写入本地驱动器,我们稍后将从中打包它们。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
构建工件 -> 构建产物?
|
||
```bash | ||
$ tar cvzf <my-app>-<my-app-version>.tar.gz -C .build/install . | ||
``` | ||
|
||
We can test the integrity of the tarball by extracting it to a directory and running the application in a Docker runtime container: | ||
我们可以通过将 tarball 解压到目录并在 Docker 运行时容器中运行应用程序来测试 tarball 的完整性: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解压到一个目录
|
||
|
||
## Source Distribution | ||
## 源分发 | ||
|
||
Another distribution technique popular with dynamic languages like Ruby or Javascript is distributing the source to the server, then compiling it on the server itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不必保留原文
|
||
|
||
## Source Distribution | ||
## 源分发 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
源代码分发
|
||
这种方法的主要优点是简单。额外的优点是服务器具有完整的工具链(例如调试器),可以帮助在服务器上“实时”排除问题。 | ||
|
||
这种方法的主要缺点是服务器具有完整的工具链(例如编译器),这意味着复杂的攻击者可能会找到执行代码的方法。他们还可能获得对源代码的访问权限,这可能是敏感的。如果应用程序代码需要从私有或受保护的存储库中克隆,服务器需要访问凭据,这增加了额外的攻击面。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
精通技术的攻击者
|
||
这种方法的主要优点是简单。额外的优点是服务器具有完整的工具链(例如调试器),可以帮助在服务器上“实时”排除问题。 | ||
|
||
这种方法的主要缺点是服务器具有完整的工具链(例如编译器),这意味着复杂的攻击者可能会找到执行代码的方法。他们还可能获得对源代码的访问权限,这可能是敏感的。如果应用程序代码需要从私有或受保护的存储库中克隆,服务器需要访问凭据,这增加了额外的攻击面。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
而这些代码可能涉及敏感信息。
No description provided.