forked from eclipse-chariott/chariott
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (39 loc) · 1.42 KB
/
Dockerfile
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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# SPDX-License-Identifier: MIT
ARG RUST_VERSION=1.65
FROM rust:${RUST_VERSION} AS builder
# Dockerfile for building Eclipse Chariott runtime container
#
# This Dockerfile utilizes a two step build process. It builds Chariott with
# statically linked dependencies (using musl) for a x86_64 architecture.
# Chariott user id
ARG CHARIOTT_UID=10001
RUN apt update && apt upgrade -y
RUN apt install -y cmake protobuf-compiler
# unprivileged identity to run Chariott as
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${CHARIOTT_UID}" \
chariott
WORKDIR /sdv
COPY ./ .
RUN rustup target add x86_64-unknown-linux-musl
RUN cargo build --release --target=x86_64-unknown-linux-musl
####################################################################################################
## Final image
####################################################################################################
FROM 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/x86_64-unknown-linux-musl/release/chariott /sdv/chariott
# Use the unprivileged chariott user during execution.
USER chariott:chariott
CMD ["./chariott"]