-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.server
77 lines (64 loc) · 2 KB
/
Dockerfile.server
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
# Copyright (c) 2024 Ho Kim (ho.kim@ulagbulag.io). All rights reserved.
# Use of this source code is governed by a GPL-3-style license that can be
# found in the LICENSE file.
# Configure environment variables
ARG PACKAGE="cassette-server"
ARG DEBIAN_IMAGE="${docker.io/library/debian}"
ARG DEBIAN_VERSION="bookworm"
ARG RUST_IMAGE="docker.io/library/rust"
ARG RUST_VERSION="1"
ARG _OS_VERSION="${DEBIAN_VERSION}"
# Be ready for serving
FROM "${DEBIAN_IMAGE}:${DEBIAN_VERSION}" AS server
# Server Configuration
EXPOSE 8080/tcp
WORKDIR /usr/local/bin
CMD [ "/bin/bash" ]
# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
hwloc \
# Cleanup
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*
# Install helm
ARG HELM_URL="https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3"
RUN apt-get update && apt-get install -y git \
&& curl "${HELM_URL}" | bash \
# Cleanup
&& apt-get remove -y git \
&& apt-get autoremove -y \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*
# Copy static files
ARG PACKAGE
ADD ./LICENSE /usr/share/licenses/${PACKAGE}/LICENSE
# Be ready for building
FROM "${RUST_IMAGE}:${RUST_VERSION}-${_OS_VERSION}" AS builder
# Install dependencies
RUN apt-get update && apt-get install -y \
cmake \
libhwloc-dev \
# Cleanup
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*
# Load source files
ADD ./Cargo.toml /src/
ADD ./crates /src/crates
WORKDIR /src
# Build it!
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 --release \
--no-default-features --features 'full,openark,rustls-tls' \
--package 'cassette-gateway' \
--package 'cassette-operator' \
&& find ./target/release/ -maxdepth 1 -type f -perm -a=x -print0 | xargs -0 -I {} mv {} /out
# Copy executable files
FROM server
COPY --from=builder /out/* /usr/local/bin/