forked from openziti/ziti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.linux-build.README
50 lines (38 loc) · 1.98 KB
/
Dockerfile.linux-build.README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Crossbuild Container for Building Linux Executables
Running this container produces three executables for each Ziti component, one for each platform architecture: amd64, arm, arm64. You may instead build for one or more of these by specifying the architecture as a parameter to the `docker run` command as shown in the example below.
## Local Development
This article supports local development by providing a local containerized method for crossbuilding Linux executables. Alternatively, you may push to your GitHub repo fork to run [the main GitHub Actions workflow](./.github/workflows/main.yaml) (CI) which will crossbuild the binaries for MacOS, Windows, and Linux. Please refer to [the main article about local development](./doc/002-local-dev.md) for help getting up and running without Docker.
## Build the Container Image
You only need to build the container image once unless you change the Dockerfile or `./linux-build.sh` (the container's entrypoint).
```bash
# find the latest Go distribution's semver
LATEST_GOLANG=$(curl -sSfL "https://go.dev/VERSION?m=text" | /bin/grep -Po '^go(\s+)?\K\d+\.\d+\.\d+$')
# build a container image named "zitibuilder" with the Dockerfile in the top-level of this repo
docker build \
--tag=zitibuilder \
--file=Dockerfile.linux-build \
--build-arg latest_golang=${LATEST_GOLANG} \
--build-arg uid=$UID \
--build-arg gid=$GID .
```
## Run the Container to Build Executables for the Desired Architectures
Executing the following `docker run` command will:
1. Mount the top-level of this repo on the container's `/mnt`
2. Run `./linux-build.sh ${@}` inside the container
3. Deposit built executables in `./release`
```bash
# build for all three architectures: amd64 arm arm64
docker run \
--rm \
--name=zitibuilder \
--volume=$PWD:/mnt \
zitibuilder
# build only amd64
docker run \
--rm \
--name=zitibuilder \
--volume=$PWD:/mnt \
zitibuilder \
amd64
```
You will find the built artifacts in `./release`.