Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (60 loc) · 2.04 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (60 loc) · 2.04 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
72
73
74
75
# syntax=docker/dockerfile:1
# 1. Import cross-compilation helpers
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
# ---------- Builder ----------
FROM --platform=$BUILDPLATFORM rust:1-bookworm AS builder
# Copy xx scripts
COPY --from=xx / /
# 2. Install NATIVE build tools (Runs on x86_64)
# We need clang (compiler), lld (linker), and pkg-config (to find libs).
RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
lld \
file \
git \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# 3. Install TARGET architecture libraries
# - libssl-dev: required for openssl-sys
# - libc6-dev: required for C headers (fixes 'bits/libc-header-start.h' error)
# - libgcc-12-dev: required for C runtime files like crtbeginS.o (fixes linker errors)
# Note: We install 'libgcc-12-dev' specifically instead of 'gcc' to avoid
# pulling in the full compiler which caused header conflicts in earlier attempts.
ARG TARGETPLATFORM
RUN xx-apt-get update && xx-apt-get install -y --no-install-recommends \
libssl-dev \
libc6-dev \
libgcc-12-dev \
libfontconfig-dev \
libsqlite3-dev
WORKDIR /build
COPY Cargo.toml Cargo.lock ./
COPY src ./src
# 4. Build using xx-cargo
# We set PKG_CONFIG env vars to ensure it finds the ARM64 libraries installed above.
RUN PKG_CONFIG_ALLOW_CROSS=1 \
PKG_CONFIG_PATH=/usr/lib/$(xx-info triple)/pkgconfig \
xx-cargo build --release && \
cp target/$(xx-cargo --print-target-triple)/release/webpipe /build/webpipe && \
xx-verify /build/webpipe
# ---------- Runtime ----------
FROM ubuntu:22.04
# Runtime libs
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
ca-certificates \
libfontconfig1 \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -r wp && useradd -r -g wp -d /app wp
WORKDIR /app
RUN mkdir -p /app/public /app/scripts && chown -R wp:wp /app
ENV WEBPIPE_PUBLIC_DIR=/app/public \
WEBPIPE_SCRIPTS_DIR=/app/scripts \
RUST_LOG=info \
PORT=8080
COPY --from=builder /build/webpipe /usr/local/bin/webpipe
USER wp
EXPOSE 8080
ENTRYPOINT ["webpipe"]
CMD ["--help"]