-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (49 loc) · 1.82 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
FROM docker.io/library/ubuntu:22.04 AS BUILD
RUN apt-get -q update \
&& DEBIAN_FRONTEND=noninteractive apt-get -q install -y \
bash \
curl \
make \
musl-dev \
musl-tools \
perl
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm \
&& ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic \
&& ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux
WORKDIR /build/openssl/
ARG OPENSSL_VERSION
RUN curl -fsSL https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz \
| tar -xz -f- --strip-components=1 -C ./ \
&& CC="musl-gcc -fPIE -pie" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64 \
&& make depend \
&& make -j4 \
&& make install_sw install_ssldirs \
&& rm -rf /build/openssl/
ENV OPENSSL_STATIC=true
ENV OPENSSL_DIR=/musl
ENV PATH=/root/.cargo/bin:$PATH
RUN curl --proto "=https" --tlsv1.2 -Sf https://sh.rustup.rs \
| bash -s -- -y --default-toolchain stable-x86_64-unknown-linux-gnu \
&& rustup target add x86_64-unknown-linux-musl
WORKDIR /build/
COPY Cargo.toml Cargo.lock ./
ARG PACKAGE_LIB
ARG PACKAGE_BIN
RUN install -d ./src/ \
&& echo "" >./src/lib.rs \
&& echo "fn main() {}" >./src/bin.rs \
&& cargo build \
--target x86_64-unknown-linux-musl \
--release \
&& find ./target/x86_64-unknown-linux-musl/ -name "$PACKAGE_LIB*" -o -name "$PACKAGE_BIN*" \
| xargs rm -rf
COPY /src/ ./src/
RUN cargo build \
--target x86_64-unknown-linux-musl \
--release \
&& strip --strip-unneeded ./target/x86_64-unknown-linux-musl/release/$PACKAGE_BIN
FROM docker.io/library/alpine:3.19 AS SERVE
ARG PACKAGE_BIN
COPY --from=BUILD /build/target/x86_64-unknown-linux-musl/release/$PACKAGE_BIN /usr/local/bin/
ENTRYPOINT []
CMD /usr/local/bin/dduct