Skip to content

Commit

Permalink
docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaylor89 committed Aug 18, 2024
1 parent 543db4a commit 55e50b9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
.vscode/
screenshot/
tests/
*.txt
*.csv
*.xlsx
devel/
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Release instructions:
# 1. Update the version tag in the Dockerfile to match the version in Cargo.toml
# 2. Update the VCS_REF tag to match the tagged version's FULL commit hash
# 3. Build image with BOTH latest and version tags
# i.e. `docker build -t sherlock/sherlocke:0.1.0 -t sherlock/sherlock:latest .`

# Stage 1: Build the Rust application
FROM rust:1.70-slim-bullseye as build

# Set the working directory inside the container
WORKDIR /sherlock

# Copy the Cargo.toml and Cargo.lock files to build the dependencies first
COPY Cargo.toml Cargo.lock ./

# Fetch dependencies and cache them
RUN cargo fetch

# Copy the rest of the application source code
COPY . .

# Build the application in release mode
RUN cargo build --release

# Stage 2: Create a minimal runtime image
FROM debian:buster-slim
WORKDIR /sherlock

ARG VCS_REF= # CHANGE ME ON UPDATE
ARG VCS_URL="https://github.com/jonaylor89/sherlock-rs"
ARG VERSION_TAG= # CHANGE ME ON UPDATE

LABEL org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.name="Sherlock" \
org.label-schema.version=$VERSION_TAG \
website="https://sherlockproject.xyz"

# Copy the compiled binary from the build stage
COPY --from=build /sherlock/target/release/myrustapp /usr/local/bin/sherlock

# Specify the entrypoint of the container
ENTRYPOINT ["sherlock"]
21 changes: 19 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct Cli {
local: bool,

/// Include checking of NSFW sites from default list.
#[clap(long, alias = "nsfw")]
#[clap(long, alias = "nsfw", default_value_t = true)]
nsfw: bool,
}

Expand All @@ -95,10 +95,27 @@ async fn main() -> Result<()> {
println!("[!!!] error path [{}]", err.path());
})?;

let targets = match cli.nsfw {
true => initial_data.targets,
false => initial_data
.targets
.into_iter()
.filter(|(_, info)| !info.is_nsfw.unwrap_or(false))
.collect(),
};

let filtered_targets = match cli.site_list.is_empty() {
true => targets,
false => targets
.into_iter()
.filter(|(site, _)| cli.site_list.contains(&site))
.collect(),
};

for username in cli.usernames {
let results = check_username(
&username,
initial_data.targets.clone(),
filtered_targets.clone(),
cli.timeout,
cli.proxy.as_ref(),
)
Expand Down
1 change: 1 addition & 0 deletions tests/status_code_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 55e50b9

Please sign in to comment.