-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (48 loc) · 1.48 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
# Copyright (c) 2024 Ho Kim ([email protected]). All rights reserved.
# Use of this source code is governed by a Apache-2.0 license that can be
# found in the LICENSE file.
# Configure environment variables
ARG DEBIAN_VERSION="bookworm"
ARG PACKAGE="cdl"
# Be ready for serving
FROM docker.io/library/debian:${DEBIAN_VERSION} AS server
# Server Configuration
WORKDIR /usr/local/bin
CMD [ "/usr/local/bin/${PACKAGE}" ]
# Install dependencies
RUN apt-get update && apt-get install -y \
fuse \
# Cleanup
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*
# Be ready for building
FROM docker.io/library/rust:1-${DEBIAN_VERSION} AS builder
# Load source files
ADD . /src
WORKDIR /src
# Install build dependencies
RUN apt-get update && apt-get install -y \
libfuse-dev \
libprotoc-dev \
protobuf-compiler \
# Cleanup
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*
# Build it!
ENV RUST_MIN_STACK=2097152
ARG PACKAGE
RUN \
# Cache build outputs
--mount=type=cache,target=/src/target \
--mount=type=cache,target=/usr/local/cargo/registry \
# Create an output directory
mkdir /out \
# Build
&& cargo build --package "${PACKAGE}" --package 'cdl-benchmark' --release \
&& mv "./target/release/${PACKAGE}" './target/release/cdl-benchmark' /out \
&& mv ./LICENSE /LICENSE
# Copy executable files
FROM server
ARG PACKAGE
COPY --from=builder /out/* /usr/local/bin/
COPY --from=builder /LICENSE /usr/share/licenses/${PACKAGE}/LICENSE