# BACKEND #
## Parent Container
FROM debian

## Creating Directories
RUN mkdir /src /app /tmp/src
WORKDIR /tmp/src

## Installing Requisites
RUN apt update -y
RUN apt install -y wget curl build-essential pkg-config libssl-dev

## Downloading RUSTUP
RUN wget https://sh.rustup.rs -O /tmp/rustup.sh
RUN chmod +x /tmp/rustup.sh
RUN /tmp/rustup.sh -y
RUN chmod +x /root/.cargo/env
RUN /root/.cargo/env

## Downloading rustup requirements
RUN /root/.cargo/bin/rustup toolchain install nightly
RUN /root/.cargo/bin/cargo install cargo-generate

## Flipper-Zero Build Target
RUN /root/.cargo/bin/rustup target add --toolchain nightly thumbv7em-none-eabihf

## Copying compile script
COPY docker/flipper-dev.sh /bin/flipper-dev.sh
RUN chmod +x /bin/flipper-dev.sh

# RUNTIME #
CMD "/bin/flipper-dev.sh"