2023-03-19 19:58:00 +00:00
|
|
|
FROM --platform=${BUILDPLATFORM} rust:1.68-bullseye AS builder
|
2023-03-19 21:04:36 +00:00
|
|
|
ARG BUILDPLATFORM
|
2023-03-19 19:58:00 +00:00
|
|
|
ARG TARGETPLATFORM
|
2022-08-09 01:09:49 +00:00
|
|
|
|
2023-03-19 19:58:00 +00:00
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get upgrade --assume-yes
|
2022-08-09 01:09:49 +00:00
|
|
|
|
2023-03-19 21:04:36 +00:00
|
|
|
RUN \
|
|
|
|
mkdir .cargo && \
|
|
|
|
echo '[net]' >> .cargo/config.toml && \
|
|
|
|
echo 'git-fetch-with-cli = true' >> .cargo/config.toml && \
|
2023-03-19 23:11:55 +00:00
|
|
|
echo >> .cargo/config.toml && \
|
2023-03-19 21:13:39 +00:00
|
|
|
if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
|
2023-03-19 23:11:55 +00:00
|
|
|
apt-get install --assume-yes gcc-x86-64-linux-gnu; \
|
2023-03-19 21:13:39 +00:00
|
|
|
echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml; \
|
|
|
|
echo 'linker = "x86-64-linux-gnu-gcc"' >> .cargo/config.toml; \
|
2023-03-19 23:11:55 +00:00
|
|
|
echo >> .cargo/config.toml; \
|
2023-03-19 21:13:39 +00:00
|
|
|
fi && \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
|
2023-03-19 23:11:55 +00:00
|
|
|
apt-get install --assume-yes gcc-aarch64-linux-gnu; \
|
2023-03-19 21:13:39 +00:00
|
|
|
echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml; \
|
|
|
|
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml; \
|
2023-03-19 23:11:55 +00:00
|
|
|
echo >> .cargo/config.toml; \
|
2023-03-19 21:13:39 +00:00
|
|
|
fi && \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
|
2023-03-19 23:11:55 +00:00
|
|
|
apt-get install --assume-yes gcc-arm-linux-gnueabihf; \
|
2023-03-19 21:13:39 +00:00
|
|
|
echo '[target.armv7-unknown-linux-gnueabihf]' >> .cargo/config.toml; \
|
|
|
|
echo 'linker = "arm-linux-gnueabihf-gcc"' >> .cargo/config.toml; \
|
2023-03-19 23:11:55 +00:00
|
|
|
echo >> .cargo/config.toml; \
|
2023-03-19 21:13:39 +00:00
|
|
|
fi \
|
2023-03-19 21:04:36 +00:00
|
|
|
fi
|
|
|
|
|
2023-03-19 23:11:55 +00:00
|
|
|
RUN \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
|
|
|
|
RUSTTARGET=x86_64-unknown-linux-gnu; \
|
|
|
|
fi && \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
|
|
|
|
RUSTTARGET=aarch64-unknown-linux-gnu; \
|
|
|
|
fi && \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
|
|
|
|
RUSTTARGET=armv7-unknown-linux-gnueabihf; \
|
|
|
|
fi && \
|
|
|
|
rustup target add ${RUSTTARGET}
|
2023-03-19 19:58:00 +00:00
|
|
|
|
|
|
|
WORKDIR /usr/src/patched_porobot/
|
|
|
|
COPY ./ ./
|
|
|
|
|
2023-03-19 23:11:55 +00:00
|
|
|
RUN \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
|
|
|
|
RUSTTARGET=x86_64-unknown-linux-gnu; \
|
|
|
|
fi && \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
|
|
|
|
RUSTTARGET=aarch64-unknown-linux-gnu; \
|
|
|
|
fi && \
|
|
|
|
if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
|
|
|
|
RUSTTARGET=armv7-unknown-linux-gnueabihf; \
|
|
|
|
fi && \
|
|
|
|
cargo build --all-features --bins --release --target=${RUSTTARGET}
|
2023-03-19 19:58:00 +00:00
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
FROM --platform=${TARGETPLATFORM} rust:1.68-slim-bullseye AS final
|
|
|
|
|
|
|
|
WORKDIR /usr/src/patched_porobot/
|
|
|
|
COPY --from=builder \
|
2023-03-19 23:11:55 +00:00
|
|
|
/usr/src/patched_porobot/target/*/release/patched_porobot_discord \
|
|
|
|
/usr/src/patched_porobot/target/*/release/patched_porobot_telegram \
|
|
|
|
/usr/src/patched_porobot/target/*/release/patched_porobot_matrix \
|
2023-03-19 19:58:00 +00:00
|
|
|
/usr/bin/
|
2023-01-31 03:43:22 +00:00
|
|
|
|
2023-04-05 10:27:35 +00:00
|
|
|
USER ${UID:-1000}:${GID:-1000}
|
2023-02-07 00:46:16 +00:00
|
|
|
ENTRYPOINT []
|
2022-12-24 02:57:48 +00:00
|
|
|
CMD []
|
2022-08-09 01:09:49 +00:00
|
|
|
|
2022-12-24 02:57:48 +00:00
|
|
|
LABEL org.opencontainers.image.title="Patched Porobot"
|
|
|
|
LABEL org.opencontainers.image.description="Legends of Runeterra card database utilities and bots"
|
|
|
|
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
|
|
|
|
LABEL org.opencontainers.image.url="https://github.com/Steffo99/patched-porobot"
|
|
|
|
LABEL org.opencontainers.image.authors="Stefano Pigozzi <me@steffo.eu>"
|
2022-08-09 01:09:49 +00:00
|
|
|
ENV RUST_LOG "warn,patched_porobot=info,patched_porobot_telegram=info,patched_porobot_discord=info,patched_porobot_matrix=info"
|