Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (52 loc) · 2.03 KB
/
Copy pathDockerfile
File metadata and controls
71 lines (52 loc) · 2.03 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
# Stage 1: Build frontend
FROM node:24-alpine AS frontend
RUN npm install -g bun@latest
WORKDIR /build/frontend-panel
COPY frontend-panel/package.json frontend-panel/bun.lock* ./
RUN bun install --frozen-lockfile
COPY frontend-panel/ ./
RUN bun run build
# Stage 2: Build Rust binary
FROM rust:1.95-alpine AS builder
RUN apk add --no-cache build-base pkgconfig sqlite-dev curl
WORKDIR /build
COPY Cargo.toml Cargo.lock* ./
COPY crates/ crates/
COPY build.rs ./
# Pre-build dependencies as a cache layer. The command may fail before all template sources are
# copied; dependency artifacts are still reused by the final build.
RUN mkdir src && echo 'fn main() {}' > src/main.rs && \
cargo build --release 2>/dev/null || true && \
rm -rf src
COPY src/ src/
COPY tests/ tests/
COPY --from=frontend /build/frontend-panel/dist/ frontend-panel/dist/
ARG CARGO_FEATURES="metrics"
ENV RUSTFLAGS="-C link-arg=-s"
RUN if [ -n "${CARGO_FEATURES}" ]; then \
cargo build --release --features "${CARGO_FEATURES}"; \
else \
cargo build --release; \
fi
# Stage 3: Alpine runtime
FROM alpine:3.23
RUN apk add --no-cache ca-certificates sqlite-libs wget && \
addgroup -S -g 10001 aster && \
adduser -S -D -H -u 10001 -G aster -s /sbin/nologin aster && \
mkdir -p /data && \
chown -R aster:aster /data
LABEL maintainer="AptS:1547 <apts-1547@esaps.net>"
LABEL org.opencontainers.image.title="aster_gate"
LABEL org.opencontainers.image.description="Aster service wired to AsterForge runtime components."
LABEL org.opencontainers.image.source="https://github.com/AsterCommunity/AsterForge"
LABEL org.opencontainers.image.license="MIT"
COPY --from=builder /build/target/release/aster_gate /usr/local/bin/aster_gate
COPY config.example.toml /config.example.toml
VOLUME ["/data"]
EXPOSE 3000
WORKDIR /
ENV ASTER__SERVER__HOST=0.0.0.0
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD ["wget", "-q", "-O", "/dev/null", "http://127.0.0.1:3000/health/ready"]
USER aster:aster
ENTRYPOINT ["/usr/local/bin/aster_gate"]