Skip to content

Commit

Permalink
Update installation docs
Browse files Browse the repository at this point in the history
  • Loading branch information
STARRY-S committed Nov 22, 2024
1 parent a4710bd commit fc4bebc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 74 deletions.
10 changes: 10 additions & 0 deletions i18n/zh/docusaurus-plugin-content-docs/version-v1.8/01-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ title: 安装指南

## 安装到 Linux 系统

### 下载二进制文件

`v1.8.7` 起,Hangar 可在 [GitHub Release 页面](https://github.com/cnrancher/hangar/releases)下载已编译的二进制文件。

```bash
wget https://github.com/cnrancher/hangar/releases/download/v1.8.7/hangar_Linux_x86_64.tar.gz
tar zxvf ./hangar_Linux_x86_64.tar.gz
cp hangar_Linux_x86_64/hangar /usr/local/bin/
```

### Arch Linux

您可在 Arch Linux [AUR](https://aur.archlinux.org/packages/hangar) 仓库获取 `PKGBUILD`,在本地编译并安装 Hangar。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,14 @@ Hangar 由 Go 语言编写。

您可参照以下步骤编译 Hangar 可执行文件:

## 在容器中构建 Hangar

1. 环境准备:

- 安装 `docker``curl``make` 依赖。
- Hangar 仅支持 Linux & Unix 系统。

1. 克隆 Hangar 源代码:
```bash
git clone https://github.com/hangar.git && cd hangar
```
1. 使用 `make`,在容器中构建 Hangar 可执行文件:
```bash
# 获取帮助信息
make help
# 在容器中构建 Hangar
make build
```
1. 编译的可执行文件可从 `bin` 目录中获取。

## 在本地构建 Hangar
## 使用 GoReleaser 构建 Hangar

1. 安装以下依赖:

- Golang >= `1.22.2`

- [goreleaser](https://goreleaser.com)

```sh
# Arch Linux
sudo pacman -S base-devel gpgme device-mapper btrfs-progs
Expand All @@ -56,21 +37,10 @@ Hangar 由 Go 语言编写。
git clone https://github.com/hangar.git && cd hangar
```

1. 执行脚本构建 Hangar
1. 使用 goreleaser 构建 hangar

```bash
./scripts/build.sh
make build
```
1. 编译的可执行文件可从 `bin` 目录中获取。

## 禁用 CGO

您可以在构建 Hangar 时添加 `DISABLE_CGO=1` 环境变量以禁用 CGO,编译不含动态链接的 Hangar 可执行文件。

:::note

禁用 CGO 编译仅用于试用。编译后的二进制文件可能在运行时出现问题,此方式并非被官方支持。

参考:[skopeo - Building a static binary](https://github.com/containers/skopeo/blob/main/install.md#building-a-static-binary)

:::
1. 编译的可执行文件可从 `dist/` 目录中获取。
12 changes: 11 additions & 1 deletion versioned_docs/version-v1.8/01-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ You can run Hangar by using the [Hangar Docker Image](#hangar-docker-image) insi

For more information about Hangar Docker Image, see [Hangar Docker Image](/docs/v1.8/docker-image) page.

## Installing on Linux
## Install to system

### Download the compiled binary

Starting from `v1.8.7`,you can download the compiled binary file from Hangar [GitHub Release page](https://github.com/cnrancher/hangar/releases).

```bash
wget https://github.com/cnrancher/hangar/releases/download/v1.8.7/hangar_Linux_x86_64.tar.gz
tar zxvf ./hangar_Linux_x86_64.tar.gz
cp hangar_Linux_x86_64/hangar /usr/local/bin/
```

### Arch Linux

Expand Down
43 changes: 6 additions & 37 deletions versioned_docs/version-v1.8/59-dev/01-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,14 @@ Hangar is written in Golang.

You can follow the below instructions to build hangar executable binary.

## Building in a container

1. Requirements:

- Ensure `docker`, `curl`, `make` installed.
- Hangar only supports Linux & Unix systems.

1. Clone the source code.
```bash
git clone https://github.com/hangar.git && cd hangar
```
1. Build hangar in container by executing `make` commands:
```bash
# Get help information
make help
# Build hangar in container
make build
```
1. The built binary file is available in `bin` directory.

## Building without a container
## Building by goreleaser

1. Install following build dependencies:

- Golang >= `1.22.2`

- [goreleaser](https://goreleaser.com)

```sh
# Arch Linux
sudo pacman -S base-devel gpgme device-mapper btrfs-progs
Expand All @@ -56,22 +37,10 @@ You can follow the below instructions to build hangar executable binary.
git clone https://github.com/hangar.git && cd hangar
```

1. Build hangar by execute build scripts manually:
1. Build hangar by goreleaser:

```bash
./scripts/build.sh
make build
```

1. The built binary file is available in the `bin` directory.

## Disable CGO

You can add `DISABLE_CGO=1` environment variable when building hangar with CGO disabled.

:::note

Keep in mind that the resulting binary is unsupported and might crash randomly. Only use if you know what you're doing!
Refer: [skopeo - Building a static binary](https://github.com/containers/skopeo/blob/main/install.md#building-a-static-binary)
:::
1. The built binary file is available in the `dist/` directory.

0 comments on commit fc4bebc

Please sign in to comment.