forked from Shadowner/Infrarust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (58 loc) · 2.02 KB
/
Dockerfile
File metadata and controls
71 lines (58 loc) · 2.02 KB
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
ARG RUST_VERSION=1.94
ARG ALPINE_VERSION=3.21
ARG NODE_VERSION=22
# Stage 1: Build the admin frontend
FROM docker.io/library/node:${NODE_VERSION}-alpine AS frontend-builder
WORKDIR /frontend
COPY plugins/infrarust-plugin-admin-api/frontend/ ./
RUN yarn install --frozen-lockfile
RUN yarn generate
# Stage 2: Build Rust binary
FROM docker.io/library/rust:${RUST_VERSION}-alpine${ALPINE_VERSION} AS builder
RUN apk add --no-cache \
musl-dev \
pkgconfig \
openssl-dev \
openssl-libs-static \
git \
build-base
WORKDIR /usr/crates/infrarust
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
COPY plugins/ ./plugins/
COPY tools/ ./tools/
COPY data/ ./data/
COPY --from=frontend-builder /frontend/.output/public/ \
./plugins/infrarust-plugin-admin-api/frontend/.output/public/
ENV OPENSSL_STATIC=1
ENV RUSTFLAGS="-C target-feature=+crt-static"
RUN ARCH=$(uname -m) && \
case "$ARCH" in \
x86_64) \
TARGET="x86_64-unknown-linux-musl" \
;; \
aarch64) \
TARGET="aarch64-unknown-linux-musl" \
;; \
armv7l) \
TARGET="armv7-unknown-linux-musleabihf" \
;; \
*) \
echo "Unsupported architecture: $ARCH" && exit 1 \
;; \
esac && \
echo "Building for target: $TARGET on architecture: $ARCH" && \
rustup target add "$TARGET" && \
cargo build --release --target "$TARGET" -p infrarust && \
cp "target/$TARGET/release/infrarust" /usr/local/bin/infrarust && \
strip /usr/local/bin/infrarust && \
echo "Build completed successfully"
# Stage 3: Runtime
FROM scratch AS runtime
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/local/bin/infrarust /sbin/infrarust
WORKDIR /app
VOLUME ["/app/config"]
EXPOSE 25565
ENTRYPOINT ["/sbin/infrarust"]
CMD ["--config", "/app/config/infrarust.toml", "--plugins-dir", "/app/config/plugins", "--servers-dir", "/app/config/servers"]