Skip to content

Conversation

@anuragbhatia
Copy link

Dockerfile to create monocle docker container based on Alpine.

Dockerfile to create monocle docker container based on Alpine.
@digizeph
Copy link
Member

digizeph commented Apr 8, 2023

It fails to build on my Mac Docker version 20.10.21, build baeda1f.

#7 65.77 error: failed to compile `monocle v0.4.0`, intermediate artifacts can be found at `/tmp/cargo-installSSgwAw`
#7 65.77 
#7 65.77 Caused by:
#7 65.77   package `clap_lex v0.4.1` cannot be built because it requires rustc 1.64.0 or newer, while the currently active rustc version is 1.60.0

@digizeph
Copy link
Member

digizeph commented Apr 9, 2023

Here is a version with debian slim base images.

# select build image
FROM rust:1.68-slim-bookworm as build

RUN DEBIAN=NONINTERACTIVE apt update; apt install -y pkg-config libssl-dev; rm -rf /var/lib/apt/lists/*

# create a new empty shell project
RUN USER=root cargo new --bin my_project
WORKDIR /my_project

# copy your source tree
COPY ./src ./src
COPY ./Cargo.toml .
COPY ./Cargo.lock .

# build for release
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo build --release

# our final base
FROM debian:bookworm-slim

# copy the build artifact from the build stage
COPY --from=build /my_project/target/release/monocle /usr/local/bin/monocle

RUN DEBIAN=NONINTERACTIVE apt update; apt install -y libssl-dev ca-certificates; rm -rf /var/lib/apt/lists/*

# have a local cache of AS information
RUN monocle whois 400644

It does not have a default ENTRYPOINT and thus you can run something like

docker run --rm monocle:debian-bookworm monocle parse http://archive.routeviews.org/route-views5/bgpdata/2023.04/UPDATES/updates.20230409.0000.bz2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants