-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
148 lines (128 loc) · 4.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
ARG BASE_IMAGE
FROM ${BASE_IMAGE} as builder
# Install deps.
RUN set -xe; \
dpkg --add-architecture i386; \
apt-get update; \
apt-get install -y \
bison \
clang \
cmake \
flex \
gcc-multilib \
git \
kmod \
libbsd-dev \
libc6-dev:i386 \
libcairo2-dev \
libcap2-bin \
libegl1-mesa-dev \
libelf-dev \
libfontconfig1-dev \
libfreetype6-dev \
libfreetype6-dev:i386 \
libfuse-dev \
libgl1-mesa-dev \
libtiff5-dev \
libudev-dev \
libxml2-dev \
linux-headers-generic \
pkg-config \
sudo \
xz-utils; \
rm -rf /var/lib/apt/lists/*;
# Clone Darling
ARG DARLING_GIT_REF="master"
RUN set -xe; \
mkdir -p /usr/local/src; \
git clone --recurse-submodules https://github.com/darlinghq/darling.git /usr/local/src/darling;
WORKDIR /usr/local/src/darling
# Checkout working gitref
RUN set -xe; \
git checkout ${DARLING_GIT_REF}; \
git submodule update --recursive; \
mkdir -p /usr/local/src/darling/build;
# Set our working directory to the build dir
WORKDIR /usr/local/src/darling/build
# Configure Darling Build
RUN set -xe; \
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ..;
# Build Darling
RUN set -xe; \
make -j$(getconf _NPROCESSORS_ONLN);
# Install Darling
RUN set -xe; \
make install; \
cp /usr/local/src/darling/build/src/startup/rtsig.h /usr/local/src/darling/rtsig.h ;\
mkdir -p /usr/local/src/darling/build/src/startup; \
mv /usr/local/src/darling/rtsig.h /usr/local/src/darling/src/startup/rtsig.h;
# Copy the modified CMakeLists.txt used for building LKM
COPY build-assets /
# Move LKM dependencies into single location
RUN set -xe; \
cd /usr/local/src/; \
rm -rf darling/build; \
mv darling darling-full; \
mkdir -p darling/src; \
mkdir -p darling/build/src; \
mv /usr/local/src/docker-darling/CMakeLists.txt /usr/local/src/darling/CMakeLists.txt ;\
mv /usr/local/src/darling-full/src/lkm /usr/local/src/darling/src/lkm ;\
mv /usr/local/src/darling-full/cmake /usr/local/src/darling/cmake; \
mv /usr/local/src/darling-full/src/bootstrap_cmds /usr/local/src/darling/src/bootstrap_cmds; \
mv /usr/local/src/darling-full/platform-include /usr/local/src/darling/platform-include; \
mv /usr/local/src/darling-full/kernel-include /usr/local/src/darling/kernel-include; \
mv /usr/local/src/darling-full/src/CMakeLists.txt /usr/local/src/darling/src/CMakeLists.txt; \
mv /usr/local/src/darling-full/src/startup /usr/local/src/darling/build/src/startup; \
rm -rf /usr/local/src/darling-full; \
rm -rf /usr/local/src/docker-darling; \
cd /usr/local/src/darling/build; \
cmake ..;
# Copy our runtime assets
COPY ./runtime-assets/ /
# Create final runtime image
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
# Create our group & user.
RUN set -xe; \
groupadd -g 1000 darling; \
useradd -g darling -u 1000 -s /bin/sh -d /home/darling darling; \
# Install deps. \
dpkg --add-architecture i386; \
apt-get update; \
apt-get install -y \
bison \
clang \
cmake \
flex \
kmod \
make \
sudo; \
rm -rf /var/lib/apt/lists/*; \
# Setup sudo access \
echo "darling ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers;
# Copy our Darling build from previous stage
COPY --from=builder /usr/local /usr/local
# Labels / Metadata.
ARG BUILD_DATE
ARG DARLING_GIT_REF
ARG VCS_REF
ARG VERSION
LABEL \
org.opencontainers.image.authors="James Brink <brink.james@gmail.com>" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.description="Darling ($VERSION)" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.source="https://github.com/utensils/docker-darling.git" \
org.opencontainers.image.title="darling (lite)" \
org.opencontainers.image.vendor="Utensils" \
org.opencontainers.image.version="git - ${DARLING_GIT_REF}"
# Setup our environment variables.
ENV PATH="/usr/local/bin:$PATH"
# Drop down to our unprivileged user.
USER darling
# Set our working directory.
WORKDIR /home/darling
# Set the entrypoint.
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Set the default command
CMD ["/usr/local/bin/darling", "shell"]