Skip to content

Build an arm64 container image #11

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM golang:1.18.3 as builder
FROM --platform=${BUILDPLATFORM} golang:1.18.3 as builder
ARG TARGETARCH
ARG TARGETOS
WORKDIR /go/src/github.com/max-rocket-internet/k8s-event-logger
COPY . .
RUN go get
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o k8s-event-logger
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o k8s-event-logger
RUN adduser --disabled-login --no-create-home --disabled-password --system --uid 101 non-root

FROM alpine:3.15.4
FROM --platform=${TARGETPLATFORM} alpine:3.15.4
RUN addgroup -S non-root && adduser -S -G non-root non-root
USER 101
ENV USER non-root
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
IMG ?= maxrocketinternet/k8s-event-logger
TAG ?= 1.6
PLATFORMS ?= linux/amd64,linux/arm64

.PHONY: image

image:
docker buildx build --platform $(PLATFORMS) --push -t $(IMG):$(TAG) .
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ Use the [Helm](https://helm.sh/) chart:
helm install chart/
```

Or user the docker image [maxrocketinternet/k8s-event-logger](https://hub.docker.com/r/maxrocketinternet/k8s-event-logger)
Or use the docker image [maxrocketinternet/k8s-event-logger][image]

[image]: https://hub.docker.com/r/maxrocketinternet/k8s-event-logger

#### Building a container image

If you're unable to use the [prebuilt][image] docker image, you can build it yourself:

```sh
make IMG=your.docker.registry/k8s-event-logger image
```

This uses `docker buildx` to create a [multi-platform image][]. To set up your build host system to be able to build these images, see [this guide][qemu-binfmt].

[multi-platform image]: https://docs.docker.com/build/building/multi-platform/
[qemu-binfmt]: https://docs.nvidia.com/datacenter/cloud-native/playground/x-arch.html

### Testing

Expand Down