-
Notifications
You must be signed in to change notification settings - Fork 47
/
Dockerfile.acceptance-testing
53 lines (49 loc) · 2.05 KB
/
Dockerfile.acceptance-testing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM golang:1.22.5 as builder
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y \
ca-certificates \
libssl-dev \
liblzma-dev \
musl-dev \
gcc \
dpkg-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /go/src/github.com/mendersoftware/deployments
COPY ./ .
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
# when building aarch64 we have to target aarch64-linux-gnu-gcc compiler
if [ "$TARGETARCH" = "arm64" ]; then \
export CC=aarch64-linux-gnu-gcc; \
export CC_FOR_TARGET=gcc-aarch64-linux-gnu; \
export OBJDUMP=aarch64-linux-gnu-objdump; \
export LD_LINUX="/lib/ld-linux-aarch64.so.1"; \
export LIBS_PATH="/usr/lib/aarch64-linux-gnu/"; \
else \
export OBJDUMP=objdump; \
export LD_LINUX="/lib64/ld-linux-x86-64.so.2"; \
export CC=gcc; \
export LIBS_PATH="/usr/lib/x86_64-linux-gnu/"; \
fi && \
CGO_ENABLED=1 GOOS=linux GOARCH=$TARGETARCH CC=$CC CC_FOR_TARGET=$CC_FOR_TARGET \
go test -c -o deployments -tags main \
-coverpkg $(go list ./... | grep -v vendor | grep -v mock | grep -v test | tr '\n' ,) && \
install -D /go/src/github.com/mendersoftware/deployments/deployments /mnt/usr/bin/deployments && \
mkdir -p /mnt/etc /mnt/tmp && \
echo 'nobody:x:65534:' > /mnt/etc/group && \
echo 'nobody:!::0:::::' > /mnt/etc/shadow && \
echo 'nobody:x:65534:65534:Nobody:/:' > /mnt/etc/passwd && \
chown -R 65534:65534 /mnt && \
install -D /etc/ssl/certs/ca-certificates.crt /mnt/etc/ssl/certs/ca-certificates.crt && \
install -D ./config.yaml /mnt/etc/deployments/config.yaml && \
install -D $LD_LINUX "/mnt${LD_LINUX}" && \
$OBJDUMP -p ./deployments | sed -nE 's/^.*NEEDED.*?(lib.+$)/\1/p' | \
while read lib; do install -D "${LIBS_PATH}${lib}" "/mnt${LIBS_PATH}${lib}"; done
FROM scratch
EXPOSE 8080
COPY --from=builder /mnt /
USER 65534
WORKDIR /etc/deployments
ENTRYPOINT ["/usr/bin/deployments", "--config", "/etc/deployments/config.yaml", "server", "--automigrate"]
STOPSIGNAL SIGINT