Skip to content

Commit

Permalink
added target.
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn authored Jul 1, 2023
1 parent 17aae60 commit 1aa384c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
31 changes: 26 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
FROM --platform=$BUILDPLATFORM rustlang/rust:nightly AS builder
RUN apt update && apt install -y protobuf-compiler
ARG TARGETARCH
RUN apt update \
&& apt upgrade -y \
&& apt install -y pkg-config libssl-dev perl make libsqlite3-dev

ARG TARGETPLATFORM
RUN case "$TARGETPLATFORM" in \
"linux/amd64") echo "x86_64-unknown-linux-gnu" > /target.txt ;; \
"linux/arm64") echo "aarch64-unknown-linux-gnu" > /target.txt ;; \
*) exit 1 ;; \
esac

RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
dpkg --add-architecture arm64 \
&& apt update \
&& apt install gcc-aarch64-linux-gnu libc6-dev-arm64-cross libsqlite3-dev:arm64 -y \
&& ln -s /usr/aarch64-linux-gnu/include/bits /usr/include/bits \
&& ln -s /usr/aarch64-linux-gnu/include/sys /usr/include/sys \
&& ln -s /usr/aarch64-linux-gnu/include/gnu /usr/include/gnu;
fi

COPY rust-toolchain.toml /
RUN rustup target add $(cat /target.txt)
COPY backend backend
COPY Cargo.toml /
COPY Cargo.lock /
RUN cargo build --release
COPY Cargo.toml Cargo.lock /
RUN cargo build --release --target $(cat /target.txt)

FROM --platform=$BUILDPLATFORM debian:bullseye-slim as runner
RUN apt update -y && apt install -y libpq-dev libssl-dev ca-certificates
RUN apt update -y && apt install -y libpq-dev libssl-dev ca-certificates
RUN update-ca-certificates
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly"
channel = "nightly-2023-06-15"
components = ["clippy", "rust-analyzer", "rustfmt", "rust-src"]

0 comments on commit 1aa384c

Please sign in to comment.