mirror of
1
Fork 0

[docs] Document non-buildx cross compilation for docker image (#1115)

* Enable / document cross compilation for docker image

* remove sudo

* explain whats up with BUILDPLATFORM/TARGETPLATFORM
This commit is contained in:
Forest Johnson 2022-11-22 11:17:41 +00:00 committed by GitHub
parent f88cb3aebc
commit 6d43319fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -330,7 +330,7 @@ If all goes according to plan, you should now have a number of multiple-architec
### Manually ### Manually
If you prefer a simple approach to building a Docker container, with fewer dependencies, you can also just build in the following way: If you prefer a simple approach to building a Docker container, with fewer dependencies (go-swagger, Node, Yarn), you can also just build in the following way:
```bash ```bash
./scripts/build.sh && docker buildx build -t superseriousbusiness/gotosocial:latest . ./scripts/build.sh && docker buildx build -t superseriousbusiness/gotosocial:latest .
@ -338,7 +338,16 @@ If you prefer a simple approach to building a Docker container, with fewer depen
The above command first builds the `gotosocial` binary, then invokes Docker buildx to build the container image. The above command first builds the `gotosocial` binary, then invokes Docker buildx to build the container image.
You don't need to install go-swagger, Node, or Yarn to build Docker images this way.
If you want to build a docker image for a different CPU architechture without setting up buildx (for example for ARMv7 aka 32-bit ARM), you can use:
```bash
GOOS=linux GOARCH=arm ./scripts/build.sh && docker build --build-arg BUILDPLATFORM=linux/amd64 --build-arg TARGETPLATFORM=linux/arm/v7 -t superseriousbusiness/gotosocial:latest .
```
See also: [exhaustive list of GOOS and GOARCH values](https://gist.github.com/lizkes/975ab2d1b5f9d5fdee5d3fa665bcfde6)
And: [exhaustive list of possible values for docker's `--platform`](https://github.com/tonistiigi/binfmt/#build-test-image)
## Financial Compensation ## Financial Compensation

View File

@ -1,6 +1,12 @@
# syntax=docker/dockerfile:1.3 # syntax=docker/dockerfile:1.3
# Dockerfile reference: https://docs.docker.com/engine/reference/builder/ # Dockerfile reference: https://docs.docker.com/engine/reference/builder/
# When using buildx, these variables will be set by the tool:
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
# However, declaring them as build arguments like this allows them to be set manually with `--build-arg` as well.
ARG BUILDPLATFORM
ARG TARGETPLATFORM
# stage 1: generate up-to-date swagger.yaml to put in the final container # stage 1: generate up-to-date swagger.yaml to put in the final container
FROM --platform=${BUILDPLATFORM} quay.io/goswagger/swagger:v0.30.0 AS swagger FROM --platform=${BUILDPLATFORM} quay.io/goswagger/swagger:v0.30.0 AS swagger