Skip to content

Commit

Permalink
Add docker build & run env
Browse files Browse the repository at this point in the history
  • Loading branch information
cndolo committed Jun 27, 2022
1 parent 5347259 commit f7e12bd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Dockerfile.crawler
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Dockerfile to build the executable binary.
# The executable is placed in /mc-crawler.
# The config is copied from the builder stage (and thus verbose from the sources).

# Get some small base image to run things on.
FROM debian:bullseye-slim AS runtime

# Create a system user to drop into.
# This will get some small (<1000) UID and GID, which is fine since we don't write to any files.
RUN groupadd -r mccrawler \
&& useradd --no-log-init -r -g mccrawler mccrawler \
&& mkdir -p mc-crawler

# Install OS dependencies.
RUN apt-get update && apt-get install -y \
libssl-dev \
build-essential #libc

# cd to working dir
WORKDIR mc-crawler

# Copy compiled binaries from builder
COPY --from=mc-crawler-builder /mc-crawler/target/release/mc-crawler .
# Copy required file with bootstrap peers from builder
COPY --from=mc-crawler-builder /mc-crawler/bootstrap.txt .

# Set ownership.
RUN chown -R mccrawler:mccrawler ./mc-crawler

# Set SGX environment variables needed by mobilecoin libraries
ENV IAS_MODE=DEV \
SGX_MODE=SW

# Drop root.
USER mccrawler

# Run the binary.
ENTRYPOINT ["./mc-crawler","--output","crawl_data", "-c"]
7 changes: 7 additions & 0 deletions build-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# This script builds two docker images in a multi-stage build, i.e.
# 1. mc-crawler-builder - this produces an image with the compiled crawler
# 2. mc-crawler - the crawler is copied from the above image into a minimal runtime environment so as to keep the image size as small as possible

docker build -t mc-crawler-builder -f Dockerfile.builder .
docker build -t mc-crawler -f Dockerfile.crawler .

0 comments on commit f7e12bd

Please sign in to comment.