Rocket's templating is not exactly friendly when it comes to embedding in-binary. Rocket's template fairing requires a `template_dir` directory pointing to the directory containing templates. A quick workaround to this would be to have custom fairings with `template_dir` merged with the value `.` But in bare-metal scenarios like what docker's scratch image mimics, we don't exactly have a '.' file, so instead for this very project, I have to point the `template_dir` to the `upload` folder, which is created by `bin` on execution. Checkout the Dockerfile for more info Signed-off-by: Gunwant Jain <mail@wantguns.dev>
33 lines
791 B
Docker
33 lines
791 B
Docker
###### Builder Image
|
|
FROM rust as builder
|
|
WORKDIR /app
|
|
COPY . .
|
|
|
|
ARG ARCH
|
|
RUN __ARCH="$(dpkg --print-architecture)"; \
|
|
[ -z $ARCH ] || __ARCH=$ARCH; \
|
|
case "$__ARCH" in \
|
|
arm64) \
|
|
export __TARGET='aarch64-unknown-linux-gnu'; \
|
|
apt update && apt upgrade -y; \
|
|
apt install -y gcc-aarch64-linux-gnu; \
|
|
rustup target add aarch64-unknown-linux-gnu; \
|
|
;; \
|
|
amd64) export __TARGET='x86_64-unknown-linux-gnu' ;; \
|
|
esac; \
|
|
cargo install --target $__TARGET --path .;
|
|
|
|
RUN cargo clean
|
|
|
|
|
|
###### Runner Image
|
|
FROM scratch as runner
|
|
COPY --from=builder /usr/local/cargo/bin/bin .
|
|
|
|
ENV BIN_ADDRESS=0.0.0.0
|
|
# Some hax required since we are running on scratch
|
|
ENV BIN_TEMPLATE_DIR=upload
|
|
EXPOSE 6162
|
|
|
|
CMD ["./bin"]
|