-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfileExtension
35 lines (28 loc) · 1.13 KB
/
DockerfileExtension
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
# FROM rust as build-stage
# ARG ARCH=x86_64
ARG TARGET_PLATFORM=linux/arm64
FROM --platform=$TARGET_PLATFORM rust:latest as build-stage
ARG ARCH=aarch64
WORKDIR /app
# Copy over manifest files
COPY ./extension/Cargo.toml ./Cargo.toml
COPY ./.cargo ./.cargo
RUN rustup target add aarch64-unknown-linux-musl
RUN rustup target add x86_64-unknown-linux-musl
# Install MUSL cross-compilation tools
RUN apt-get update && \
apt-get install -y musl-tools
# RUN source $HOME/.cargo/env && cargo --version
# This dummy build is to get the dependencies cached
RUN mkdir src && \
echo 'fn main() {println!("if you see this, the build broke")}' > src/main.rs &&\
export PATH=$PATH:/${ARCH}-linux-musl-cross/bin/ &&\
CC=${ARCH}-linux-musl-gcc cargo build --release --target=${ARCH}-unknown-linux-musl
ADD ./extension/ .
RUN touch src/main.rs &&\
export PATH=$PATH:/${ARCH}-linux-musl-cross/bin/ &&\
CC=${ARCH}-linux-musl-gcc cargo build --release --target=${ARCH}-unknown-linux-musl
FROM scratch AS package-stage
# ARG ARCH=x86_64
ARG ARCH=aarch64
COPY --from=build-stage /app/target/${ARCH}-unknown-linux-musl/release/extension /lambda-dispatch