Skip to content

Commit d952e3d

Browse files
authored
Merge pull request #692 from RoEdAl/docker-march
Docker: build mulitarchitecture images
2 parents 230b08f + 9fd0607 commit d952e3d

File tree

4 files changed

+110
-25
lines changed

4 files changed

+110
-25
lines changed
Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
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+
if: github.event_name != 'pull_request'
19+
uses: docker/setup-qemu-action@v3
20+
with:
21+
platforms: arm,arm64
22+
cache-image: false
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
1725
- name: Docker meta
1826
id: meta
1927
uses: docker/metadata-action@v5
@@ -28,19 +36,34 @@ jobs:
2836
type=semver,pattern={{version}}
2937
type=semver,pattern={{major}}.{{minor}}
3038
type=semver,pattern={{major}}.{{minor}}.{{patch}}
31-
- name: Login to ghcr.io
39+
env:
40+
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
41+
- name: Login to GitHub Container Registry
3242
if: github.event_name != 'pull_request'
3343
uses: docker/login-action@v3
3444
with:
3545
registry: ghcr.io
3646
username: ${{ github.actor }}
3747
password: ${{ secrets.GITHUB_TOKEN }}
48+
- name: Build
49+
if: github.event_name == 'pull_request'
50+
uses: docker/build-push-action@v6
51+
with:
52+
context: .
53+
platforms: linux/amd64
54+
push: false
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
annotations: ${{ steps.meta.outputs.annotations }}
3858
- name: Build and push
39-
id: docker_build
59+
if: github.event_name != 'pull_request'
4060
uses: docker/build-push-action@v6
4161
with:
42-
# push for non-pr events
43-
push: ${{ github.event_name != 'pull_request' }}
4462
context: .
63+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
64+
push: true
4565
tags: ${{ steps.meta.outputs.tags }}
4666
labels: ${{ steps.meta.outputs.labels }}
67+
annotations: ${{ steps.meta.outputs.annotations }}
68+
cache-from: type=gha
69+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
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 --network=none make clean
10+
RUN --mount=type=cache,id=go-cache,target=/.cache,sharing=locked,uid=65534,gid=65534 make go-carbon
11+
RUN --mount=type=cache,id=go-cache,target=/.cache,sharing=locked,uid=65534,gid=65534 <<EOT
12+
if [ "${TARGETARCH:-unknown}" = "amd64" ]; then
13+
make run-test COMMAND="test -race"
14+
else
15+
make run-test COMMAND="test" || true
16+
fi
17+
EOT
1018

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
19+
FROM alpine:latest
1420

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

1930
USER carbon
20-
CMD ["/usr/sbin/go-carbon", "-daemon=false", "-config", "/etc/go-carbon/go-carbon.conf"]
31+
ENTRYPOINT ["/usr/sbin/go-carbon"]
32+
CMD ["-config", "/etc/go-carbon/go-carbon.conf"]
2133

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

carbon/config.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,14 @@ type Config struct {
212212
}
213213

214214
func NewLoggingConfig() zapwriter.Config {
215-
cfg := zapwriter.NewConfig()
216-
cfg.File = "/var/log/go-carbon/go-carbon.log"
217-
return cfg
215+
return zapwriter.Config{
216+
Logger: "",
217+
File: "stdout",
218+
Level: "info",
219+
Encoding: "console",
220+
EncodingTime: "iso8601",
221+
EncodingDuration: "seconds",
222+
}
218223
}
219224

220225
// NewConfig ...

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)