-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
57 lines (49 loc) · 1.46 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
FROM dart:latest AS builder
# Get dependencies
RUN \
export DEBIAN_FRONTEND=noninteractive \
&& apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
ca-certificates \
libsqlite3-0 \
libsqlite3-dev \
zip \
git \
llvm \
curl \
gnupg \
build-essential \
pkg-config \
libssl-dev \
libclang-dev \
apt-transport-https \
wget
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:$PATH"
RUN echo 'export PATH="/root/.cargo/bin:$PATH"' >> ~/.profile
WORKDIR /app
COPY . .
# And build
RUN dart pub get \
&& cd rust \
&& cargo build --release \
&& cd .. \
&& mkdir -p bin \
&& cp rust/target/release/librust.so . \
&& dart compile exe bin/s5_server.dart -o bin/s5_server \
&& chmod +x bin/s5_server \
&& mkdir -p /runtime/lib \
&& ldd bin/s5_server | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /runtime/lib/ \
&& ldd librust.so | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /runtime/lib/ \
&& find / -name libsqlite3.so | xargs -I '{}' cp -v '{}' /runtime/lib/
# Copy build to fresh image because without doing this the image
# is like 5.6GB lol (it's now like 22MB!)
FROM scratch
COPY --from=builder /runtime/ /
COPY --from=builder /app/librust.so /app/librust.so
COPY --from=builder /app/bin/s5_server /app/bin/
ENV DOCKER=TRUE
# Start server.
EXPOSE 5050
CMD ["/app/bin/s5_server"]