Closed juddbaguio closed 4 months ago
I used the following Dockerfile instead:
# Using the `rust-musl-builder` as base image, instead of
# the official Rust toolchain
FROM clux/muslrust:nightly AS chef
USER root
RUN cargo +nightly install cargo-chef
WORKDIR /prc-physician-license-validator-api
FROM chef AS planner
COPY . .
RUN cargo +nightly chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /prc-physician-license-validator-api/recipe.json recipe.json
# Notice that we are specifying the --target flag!
RUN cargo +nightly chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
COPY . .
RUN cargo +nightly build --release --target x86_64-unknown-linux-musl
FROM alpine AS runtime
USER root
RUN apk upgrade --no-cache --available \
&& apk add --no-cache \
chromium-swiftshader \
ttf-freefont \
font-noto-emoji \
&& apk add --no-cache \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \
font-wqy-zenhei
ENV CHROME_BIN=/usr/bin/chromium-browser \
CHROME_PATH=/usr/lib/chromium/
WORKDIR /app
COPY --from=builder /prc-physician-license-validator-api/target/x86_64-unknown-linux-musl/release/prc-physician-license-validator-api .
EXPOSE 8080
CMD ["./prc-physician-license-validator-api"]
And updated the BrowserConfig
to the following snippet:
let default_config = BrowserConfig::builder().no_sandbox().build().unwrap();
I have created a REST API to do some headless chromium automation using Axum. This is the handler's logic.
And the way I setup my binaries, the browser config, and the router
When ran locally, it's working but upon deploying it with Docker and calling the API endpoint. I receive the following logs below:
For context, this is the Dockerfile that I am using.
Edit: I used docker desktop to traverse the current working directory of the container. Based from the image below, chrome is existent.