Skip to content

Commit a1581ec

Browse files
authored
Merge pull request #386 from fluxcd/armv7-goldlink-patch
Use Debian instead of Alpine for multi-arch builds
2 parents 44dd9d7 + 7e6b88e commit a1581ec

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

Dockerfile

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
# Docker buildkit multi-arch build requires golang alpine
2-
FROM golang:1.16-alpine as builder
3-
4-
RUN apk add --no-cache gcc pkgconfig libc-dev binutils-gold musl~=1.2 libgit2-dev~=1.1
1+
FROM golang:1.16-buster as builder
2+
3+
# Up-to-date libgit2 dependencies are only available in
4+
# >=bullseye (testing).
5+
RUN echo "deb http://deb.debian.org/debian testing main" >> /etc/apt/sources.list \
6+
&& echo "deb-src http://deb.debian.org/debian testing main" >> /etc/apt/sources.list
7+
RUN set -eux; \
8+
apt-get update \
9+
&& apt-get install -y libgit2-dev/testing zlib1g-dev/testing libssh2-1-dev/testing libpcre3-dev/testing \
10+
&& apt-get clean \
11+
&& apt-get autoremove --purge -y \
12+
&& rm -rf /var/lib/apt/lists/*
513

614
WORKDIR /workspace
715

@@ -24,21 +32,26 @@ COPY internal/ internal/
2432
# build without specifing the arch
2533
RUN CGO_ENABLED=1 go build -o source-controller main.go
2634

27-
FROM alpine:3.13
35+
FROM debian:buster-slim as controller
2836

2937
# link repo to the GitHub Container Registry image
3038
LABEL org.opencontainers.image.source="https://github.com/fluxcd/source-controller"
3139

32-
RUN apk add --no-cache ca-certificates tini libgit2~=1.1 musl~=1.2
40+
# Up-to-date libgit2 dependencies are only available in
41+
# >=bullseye (testing).
42+
RUN echo "deb http://deb.debian.org/debian testing main" >> /etc/apt/sources.list \
43+
&& echo "deb-src http://deb.debian.org/debian testing main" >> /etc/apt/sources.list
44+
RUN set -eux; \
45+
apt-get update \
46+
&& apt-get install -y ca-certificates libgit2-1.1 \
47+
&& apt-get clean \
48+
&& apt-get autoremove --purge -y \
49+
&& rm -rf /var/lib/apt/lists/*
3350

3451
COPY --from=builder /workspace/source-controller /usr/local/bin/
3552

36-
# Create minimal nsswitch.conf file to prioritize the usage of /etc/hosts over DNS queries.
37-
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-354316460
38-
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
39-
40-
RUN addgroup -S controller && adduser -S controller -G controller
53+
RUN groupadd controller && \
54+
useradd --gid controller --shell /bin/sh --create-home controller
4155

4256
USER controller
43-
44-
ENTRYPOINT [ "/sbin/tini", "--", "source-controller" ]
57+
ENTRYPOINT ["source-controller"]

0 commit comments

Comments
 (0)