-
Notifications
You must be signed in to change notification settings - Fork 20
/
Dockerfile
115 lines (103 loc) · 3.88 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
# Define base arguments for versioning and optimization
ARG RUST_NIGHTLY_VERSION=nightly-2024-10-22
ARG RUST_TARGET_CPU=native
ARG RUSTFLAGS="-C target-cpu=${RUST_TARGET_CPU} -Z share-generics=y -Z threads=8 --cfg tokio_unstable"
ARG CARGO_HOME=/usr/local/cargo
# Use Ubuntu as base image
FROM ubuntu:22.04 AS packages
# Prevent apt from prompting for user input
ENV DEBIAN_FRONTEND=noninteractive
# Install essential build packages
RUN apt-get update && \
apt-get install -y \
curl \
build-essential \
libssl-dev \
pkg-config \
cmake \
perl \
gcc \
linux-headers-generic \
&& rm -rf /var/lib/apt/lists/*
# Base builder stage with Rust installation
FROM packages AS builder-base
ARG RUST_NIGHTLY_VERSION
ARG RUSTFLAGS
ARG CARGO_HOME
ENV RUSTFLAGS=${RUSTFLAGS}
ENV CARGO_HOME=${CARGO_HOME}
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST_NIGHTLY_VERSION} && \
$CARGO_HOME/bin/rustup component add rust-src && \
$CARGO_HOME/bin/rustc --version
ENV PATH="${CARGO_HOME}/bin:${PATH}"
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates
COPY events ./events
RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
cargo fetch
# Debug builder
FROM builder-base AS build-debug
ARG CARGO_HOME
RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
cargo build --frozen && \
mkdir -p /app/build && \
cp target/debug/hyperion-proxy /app/build/ && \
cp target/debug/proof-of-concept /app/build/
# Release builder
FROM builder-base AS build-release
ARG CARGO_HOME
RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
cargo build --profile release-full --frozen && \
mkdir -p /app/build && \
cp target/release-full/hyperion-proxy /app/build/ && \
cp target/release-full/proof-of-concept /app/build/
# Runtime base image
FROM ubuntu:22.04 AS runtime-base
RUN apt-get update && \
apt-get install -y \
libssl3 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ENV RUST_BACKTRACE=1 \
RUST_LOG=info
# Hyperion Proxy Debug
FROM runtime-base AS hyperion-proxy-debug
COPY --from=build-debug /app/build/hyperion-proxy /
LABEL org.opencontainers.image.source="https://github.com/yourusername/hyperion-proxy" \
org.opencontainers.image.description="Debug Build - Hyperion Proxy Server" \
org.opencontainers.image.version="1.0.0"
EXPOSE 8080
ENTRYPOINT ["/hyperion-proxy"]
CMD ["0.0.0.0:8080"]
# Hyperion Proxy Release
FROM runtime-base AS hyperion-proxy-release
COPY --from=build-release /app/build/hyperion-proxy /
LABEL org.opencontainers.image.source="https://github.com/yourusername/hyperion-proxy" \
org.opencontainers.image.description="Release Build - Hyperion Proxy Server" \
org.opencontainers.image.version="1.0.0"
EXPOSE 8080
ENTRYPOINT ["/hyperion-proxy"]
CMD ["0.0.0.0:8080"]
# NYC Debug
FROM runtime-base AS proof-of-concept-debug
COPY --from=build-debug /app/build/proof-of-concept /
LABEL org.opencontainers.image.source="https://github.com/yourusername/proof-of-concept" \
org.opencontainers.image.description="Debug Build - NYC Server" \
org.opencontainers.image.version="1.0.0"
ENTRYPOINT ["/proof-of-concept"]
CMD ["--ip", "0.0.0.0", "--port", "35565"]
# NYC Release
FROM runtime-base AS proof-of-concept-release
COPY --from=build-release /app/build/proof-of-concept /
LABEL org.opencontainers.image.source="https://github.com/yourusername/proof-of-concept" \
org.opencontainers.image.description="Release Build - NYC Server" \
org.opencontainers.image.version="1.0.0"
ENTRYPOINT ["/proof-of-concept"]
CMD ["--ip", "0.0.0.0", "--port", "35565"]