Templates: embed the templates in-binary
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>
This commit is contained in:
14
Dockerfile
14
Dockerfile
@@ -2,8 +2,6 @@
|
||||
FROM rust as builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
# scratch does not have the mkdir binary, so we create a folder here
|
||||
RUN mkdir -p empty_upload
|
||||
|
||||
ARG ARCH
|
||||
RUN __ARCH="$(dpkg --print-architecture)"; \
|
||||
@@ -24,15 +22,11 @@ RUN cargo clean
|
||||
|
||||
###### Runner Image
|
||||
FROM scratch as runner
|
||||
COPY --from=builder /app/empty_upload upload
|
||||
COPY ./contrib/cli/client upload/client
|
||||
COPY ./templates templates
|
||||
COPY ./static static
|
||||
COPY ./themes themes
|
||||
COPY --from=builder /usr/local/cargo/bin/bin .
|
||||
|
||||
ENV ROCKET_ADDRESS=0.0.0.0
|
||||
ENV ROCKET_PORT=6162
|
||||
|
||||
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"]
|
||||
|
||||
Reference in New Issue
Block a user