-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile.service_discovery.arm64
62 lines (45 loc) · 1.79 KB
/
Dockerfile.service_discovery.arm64
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
54
55
56
57
58
59
60
61
62
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# SPDX-License-Identifier: MIT
ARG RUST_VERSION=1.70
FROM docker.io/library/rust:${RUST_VERSION} AS builder
# Dockerfile for building Eclipse Chariott Service Discovery container
#
# This Dockerfile utilizes a two step build process. It builds Chariott
# Service Discovery with statically linked dependencies (using musl)
# for an arm64 architecture.
# Chariott user id
ARG CHARIOTT_UID=10001
RUN apt update && apt upgrade -y
RUN apt install -y cmake protobuf-compiler gcc-aarch64-linux-gnu
WORKDIR /sdv
COPY ./ .
# Check that CHARIOTT_UID argument is valid.
RUN /sdv/container/scripts/argument_sanitizer.sh \
--arg-value "${CHARIOTT_UID}" \
--regex "^[0-9]+$" || \
( echo "Argument sanitizer failed for ARG 'CHARIOTT_UID'"; exit 1 )
# unprivileged identity to run Chariott Service Discovery as
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${CHARIOTT_UID}" \
chariott
RUN rustup target add aarch64-unknown-linux-musl
RUN cargo build --release --target=aarch64-unknown-linux-musl -p service_discovery
####################################################################################################
## Final image
####################################################################################################
FROM arm64v8/alpine:latest
# Import Chariott user and group from builder.
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
WORKDIR /sdv
# Copy our build
COPY --from=builder /sdv/target/aarch64-unknown-linux-musl/release/service_discovery /sdv/service_discovery
# Use the unprivileged chariott user during execution.
USER chariott:chariott
CMD ["./service_discovery"]