Skip to content

Commit d396fd0

Browse files
committed
Docker: build multiarchitecture images
1 parent eb53439 commit d396fd0

File tree

3 files changed

+89
-22
lines changed

3 files changed

+89
-22
lines changed
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
name: Upload Docker images to ghcr.io
1+
name: Upload Docker images to GitHub Container Registry (ghcr.io)
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, main ]
66
tags: [ 'v*' ]
77
pull_request:
8-
branches: [ master ]
8+
branches: [ master, main ]
99

1010
jobs:
1111
docker:
12-
name: Build image
12+
name: Build images
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Check out code
1616
uses: actions/checkout@v4
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v3
19+
with:
20+
platforms: arm,arm64
21+
cache-image: false
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
1724
- name: Docker meta
1825
id: meta
1926
uses: docker/metadata-action@v5
@@ -28,19 +35,23 @@ jobs:
2835
type=semver,pattern={{version}}
2936
type=semver,pattern={{major}}.{{minor}}
3037
type=semver,pattern={{major}}.{{minor}}.{{patch}}
31-
- name: Login to ghcr.io
38+
env:
39+
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
40+
- name: Login to GitHub Container Registry
3241
if: github.event_name != 'pull_request'
3342
uses: docker/login-action@v3
3443
with:
3544
registry: ghcr.io
3645
username: ${{ github.actor }}
3746
password: ${{ secrets.GITHUB_TOKEN }}
3847
- name: Build and push
39-
id: docker_build
4048
uses: docker/build-push-action@v6
4149
with:
42-
# push for non-pr events
43-
push: ${{ github.event_name != 'pull_request' }}
4450
context: .
51+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
52+
push: ${{ github.event_name != 'pull_request' }}
4553
tags: ${{ steps.meta.outputs.tags }}
4654
labels: ${{ steps.meta.outputs.labels }}
55+
annotations: ${{ steps.meta.outputs.annotations }}
56+
cache-from: type=gha
57+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
1-
FROM golang:1.23-alpine AS build
1+
FROM golang:alpine AS build
2+
ARG TARGETARCH
23

3-
COPY . /usr/local/src/go-carbon
4-
RUN apk add --update git make bash \
5-
&& cd /usr/local/src/go-carbon \
6-
&& make go-carbon \
7-
&& chmod +x go-carbon && cp -fv go-carbon /tmp
4+
RUN apk add --update git make bash gcc musl-dev
85

9-
FROM alpine:3
6+
USER nobody:nogroup
7+
WORKDIR /usr/local/src/go-carbon
8+
COPY --chown=nobody:nogroup . .
9+
RUN --mount=type=cache,id=go-cache,target=/.cache,sharing=locked,uid=65534,gid=65534 make go-carbon
10+
RUN --mount=type=cache,id=go-cache,target=/.cache,sharing=locked,uid=65534,gid=65534 <<EOT
11+
if [ "${TARGETARCH:-unknown}" = "amd64" ]; then
12+
make run-test COMMAND="test -race"
13+
else
14+
make run-test COMMAND="test" || true
15+
fi
16+
EOT
1017

11-
RUN addgroup -S carbon && adduser -S carbon -G carbon \
12-
&& mkdir -p /var/lib/graphite/whisper /var/lib/graphite/dump /var/lib/graphite/tagging /var/log/go-carbon /etc/go-carbon/ \
13-
&& chown -R carbon:carbon /var/lib/graphite/ /var/log/go-carbon
18+
FROM alpine:latest
1419

15-
COPY --from=build /tmp/go-carbon /usr/sbin/go-carbon
16-
ADD go-carbon.conf.example /etc/go-carbon/go-carbon.conf
20+
RUN --network=none addgroup -S carbon && adduser -S carbon -G carbon \
21+
&& mkdir -p /var/lib/graphite/whisper /etc/go-carbon/ \
22+
&& chown -R carbon:carbon /var/lib/graphite/
23+
24+
COPY --chown=0:0 --from=build /usr/local/src/go-carbon/go-carbon /usr/sbin/go-carbon
25+
ADD go-carbon.docker.conf /etc/go-carbon/go-carbon.conf
1726
ADD deploy/storage*.conf /etc/go-carbon/
27+
RUN --network=none /usr/sbin/go-carbon -config-print-default > /etc/go-carbon/go-carbon.default.conf
1828

1929
USER carbon
20-
CMD ["/usr/sbin/go-carbon", "-daemon=false", "-config", "/etc/go-carbon/go-carbon.conf"]
30+
ENTRYPOINT ["/usr/sbin/go-carbon"]
31+
CMD ["-config", "/etc/go-carbon/go-carbon.conf"]
2132

22-
EXPOSE 2003 2004 7002 7003 7007 8080 2003/udp
33+
EXPOSE 2003/tcp 2003/udp 8080
2334
VOLUME /var/lib/graphite /etc/go-carbon

go-carbon.docker.conf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[whisper]
2+
enabled = true
3+
data-dir = "/var/lib/graphite/whisper"
4+
schemas-file = "/etc/go-carbon/storage-schemas.conf"
5+
aggregation-file = "/etc/go-carbon/storage-aggregation.conf"
6+
sparse-create = true
7+
8+
[cache]
9+
max-size = 1000000
10+
write-strategy = "noop"
11+
bloom-size = 0
12+
13+
[udp]
14+
listen = ":2003"
15+
enabled = true
16+
buffer-size = 0
17+
18+
[tcp]
19+
listen = ":2003"
20+
enabled = true
21+
buffer-size = 0
22+
23+
[carbonserver]
24+
listen = ":8080"
25+
enabled = true
26+
27+
[pickle]
28+
enabled = false
29+
30+
[grpc]
31+
enabled = false
32+
33+
[carbonlink]
34+
enabled = false
35+
36+
[dump]
37+
enabled = false
38+
39+
[[logging]]
40+
logger = ""
41+
file = "stdout"
42+
level = "error"
43+
encoding = "console"
44+
encoding-time = ""
45+
encoding-duration = ""

0 commit comments

Comments
 (0)