-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker: build multiarchitecture images
- Build images without Cairo library. - Skip entirely broken tests routines of countValues function.
- Loading branch information
Showing
5 changed files
with
106 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,71 @@ | ||
name: Upload Docker images to ghcr.io | ||
name: Upload Docker images to GitHub Container Registry (ghcr.io) | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: 'Git tag to push the image' | ||
required: true | ||
type: string | ||
push: | ||
branches: [ master, main ] | ||
tags: [ 'v*' ] | ||
pull_request: | ||
branches: [ master, main ] | ||
|
||
jobs: | ||
docker: | ||
name: Build image | ||
name: Build images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
if: github.event_name != 'pull_request' | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
platforms: arm,arm64 | ||
cache-image: false | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
context: ${{ inputs.ref && 'git' || 'workflow' }} | ||
images: ghcr.io/${{ github.repository }} | ||
# create latest tag for branch events | ||
flavor: | | ||
latest=${{ inputs.ref && 'false' || 'auto' }} | ||
latest=${{ github.event_name == 'push' && github.ref_type == 'branch' }} | ||
tags: | | ||
type=semver,pattern={{version}},value=${{inputs.ref}} | ||
type=semver,pattern={{major}}.{{minor}},value=${{inputs.ref}} | ||
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{inputs.ref}} | ||
- name: Login to ghcr.io | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}}.{{minor}}.{{patch}} | ||
env: | ||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | ||
- name: Login to GitHub Container Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build | ||
if: github.event_name == 'pull_request' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
annotations: ${{ steps.meta.outputs.annotations }} | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
if: github.event_name != 'pull_request' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
# push for non-pr events | ||
push: ${{ github.event_name != 'pull_request' }} | ||
context: . | ||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
annotations: ${{ steps.meta.outputs.annotations }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
FROM golang:alpine as builder | ||
|
||
LABEL org.opencontainers.image.source https://github.com/go-graphite/carbonapi | ||
|
||
WORKDIR /go/src/github.com/go-graphite/carbonapi | ||
|
||
COPY . . | ||
|
||
RUN apk --no-cache add make gcc git cairo-dev musl-dev | ||
RUN make && make test | ||
FROM golang:alpine AS builder | ||
ARG TARGETARCH | ||
|
||
RUN apk --no-cache add --update make gcc git musl-dev | ||
|
||
USER nobody:nogroup | ||
WORKDIR /usr/local/src/carbonapi | ||
COPY --chown=nobody:nogroup . . | ||
RUN --network=none make clean | ||
RUN --mount=type=cache,id=go-cache,target=/.cache,sharing=locked,uid=65534,gid=65534 make nocairo | ||
RUN --mount=type=cache,id=go-cache,target=/.cache,sharing=locked,uid=65534,gid=65534 <<EOT | ||
if [ "${TARGETARCH:-unknown}" = "amd64" ]; then | ||
make test_nocairo | ||
else | ||
make test_nocairo_norace | ||
fi | ||
EOT | ||
|
||
# If you have "Operation not permitted" errors, please refer to https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0#faccessat2 | ||
# TLDR; Either update docker/moby and libseccomp or switch to alpine:3.13 (builder needs to be switched to 1.16-alpine3.13 as well). | ||
# See https://github.com/go-graphite/carbonapi/issues/639#issuecomment-896570456 for detailed information | ||
FROM alpine:latest | ||
|
||
RUN apk --no-cache add ca-certificates cairo | ||
WORKDIR / | ||
RUN addgroup -S carbon && \ | ||
adduser -S carbon -G carbon && \ | ||
apk --no-cache add --update ca-certificates | ||
|
||
COPY --chown=0:0 --from=builder /usr/local/src/carbonapi/carbonapi /usr/sbin/carbonapi | ||
WORKDIR /etc/carbonapi | ||
COPY --chown=0:0 --from=builder /usr/local/src/carbonapi/cmd/carbonapi/carbonapi.docker.yaml carbonapi.yaml | ||
|
||
COPY --from=builder /go/src/github.com/go-graphite/carbonapi/carbonapi ./usr/bin/carbonapi | ||
WORKDIR / | ||
USER carbon | ||
ENTRYPOINT ["/usr/sbin/carbonapi"] | ||
CMD ["-config", "/etc/carbonapi/carbonapi.yaml"] | ||
|
||
CMD ["carbonapi", "-config", "/etc/carbonapi.yml"] | ||
EXPOSE 8080 | ||
VOLUME /etc/carbonapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
listeners: | ||
- address: ':8080' | ||
|
||
idleConnections: 1 | ||
|
||
upstreams: | ||
keepAliveInterval: 120s | ||
tldCacheDisabled: true | ||
backendsv2: | ||
backends: | ||
- groupName: carbon | ||
protocol: carbonapi_v3_pb | ||
lbMethod: any | ||
servers: | ||
- 'http://carbon:8080' | ||
|
||
logger: | ||
- logger: '' | ||
file: stdout | ||
level: error | ||
encoding: console | ||
encodingTime: '' | ||
encodingDuration: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters