From 354c1945e5f77b3c5ab72848c9db5604d0dfc316 Mon Sep 17 00:00:00 2001 From: mandysulli Date: Mon, 9 Jun 2025 15:50:38 -0400 Subject: [PATCH 1/6] start containerization --- .gitignore | 1 + Dockerfile | 90 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 18 ++++++++++ 3 files changed, 109 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 2910fda..75d6311 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /test *test* *lock +*crt \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..38b3564 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,90 @@ +# Create an argument to pull a particular version of an image +ARG rust_image +ARG rust_image=${rust_image:-rust:alpine3.21} + +#################################################################################################### +# BASE IMAGE +#################################################################################################### +FROM ${rust_image} AS base + +# Required certs for apk update +COPY ca.crt /root/ca.crt + +# Put certs in /etc/ssl/certs location +RUN cat /root/ca.crt >> /etc/ssl/certs/ca-certificates.crt + +# Install system libraries of general use +RUN apk update && apk add --no-cache \ + bash \ + vim \ + tar \ + dos2unix \ + build-base \ + musl-dev \ + openssl-dev \ + pkgconfig + +##update to rust nightly +RUN rustup toolchain install nightly + +RUN rustup override set nightly + +############# Copy everything into conatiner ################## +# Create working directory variable +ENV PROJECT_DIR=/mira-oxide + +# Copy all scripts to docker images +COPY . . + +# This build step will cache the dependencies +RUN cargo build --release + +# Set the entrypoint +#CMD ["./target/release/*"] + +#COPY ./target/release/* ${PROJECT_DIR}/target/release/* + +#RUN chmod -R 777 ${PROJECT_DIR}/target/release/* + +############# Fix vulnerablities pkgs ################## + + +# Convert bash script from Windows style line endings to Unix-like control characters +#RUN dos2unix ${PROJECT_DIR}/fixed_vulnerability_pkgs.sh + +# Allow permission to excute the bash script +#RUN chmod a+x ${PROJECT_DIR}/fixed_vulnerability_pkgs.sh + +# Execute bash script to wget the file and tar the package +#RUN bash ${PROJECT_DIR}/fixed_vulnerability_pkgs.sh + +############# Remove vulnerability pkgs ################## + +# Copy all files to docker images +#COPY docker_files/remove_vulnerability_pkgs.txt ${PROJECT_DIR}/remove_vulnerability_pkgs.txt + +# Copy all files to docker images +#COPY docker_files/remove_vulnerability_pkgs.sh ${PROJECT_DIR}/remove_vulnerability_pkgs.sh + +# Convert bash script from Windows style line endings to Unix-like control characters +#RUN dos2unix ${PROJECT_DIR}/remove_vulnerability_pkgs.sh + +# Allow permission to excute the bash script +#RUN chmod a+x ${PROJECT_DIR}/remove_vulnerability_pkgs.sh + +# Execute bash script to wget the file and tar the package +#RUN bash ${PROJECT_DIR}/remove_vulnerability_pkgs.sh + +############# Set up working directory ################## + +# Create working directory variable +ENV WORKDIR=${PROJECT_DIR}/data + +# Set up volume directory in docker +VOLUME ${WORKDIR} + +# Set up working directory in docker +WORKDIR ${WORKDIR} + +# Export project directory to PATH +ENV PATH "$PATH:/target/release" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9a614f2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +x-rust-image: &rust-image rust:alpine3.21 + +x-data-volume: &data-volume + type: bind + source: /home/xpa3/mira-oxide/test + target: /mira-oxide/data + +services: + mira-oxide: + container_name: mira-oxide + image: mira-oxide:latest + build: + context: . + dockerfile: Dockerfile + restart: always + volumes: + - *data-volume + command: tail -f /dev/null From f29854e8f095423575b79ca3c92a445f0e6f36b9 Mon Sep 17 00:00:00 2001 From: mandysulli Date: Tue, 10 Jun 2025 11:22:56 -0400 Subject: [PATCH 2/6] improving Dockerfile --- Dockerfile | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38b3564..8d7b726 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,19 +19,14 @@ RUN apk update && apk add --no-cache \ vim \ tar \ dos2unix \ - build-base \ - musl-dev \ - openssl-dev \ - pkgconfig + build-base ##update to rust nightly RUN rustup toolchain install nightly RUN rustup override set nightly -############# Copy everything into conatiner ################## -# Create working directory variable -ENV PROJECT_DIR=/mira-oxide +############# Copy everything into conatiner then build ################## # Copy all scripts to docker images COPY . . @@ -39,16 +34,12 @@ COPY . . # This build step will cache the dependencies RUN cargo build --release -# Set the entrypoint -#CMD ["./target/release/*"] - -#COPY ./target/release/* ${PROJECT_DIR}/target/release/* - -#RUN chmod -R 777 ${PROJECT_DIR}/target/release/* +RUN rm -rf /var/lib/{apt,dpkg,cache,log}/ \ + /target/debug \ + /git* ############# Fix vulnerablities pkgs ################## - # Convert bash script from Windows style line endings to Unix-like control characters #RUN dos2unix ${PROJECT_DIR}/fixed_vulnerability_pkgs.sh @@ -78,7 +69,7 @@ RUN cargo build --release ############# Set up working directory ################## # Create working directory variable -ENV WORKDIR=${PROJECT_DIR}/data +ENV WORKDIR=/data # Set up volume directory in docker VOLUME ${WORKDIR} From f0e5d389543d2584094b4938224450d4edfd244c Mon Sep 17 00:00:00 2001 From: mandysulli Date: Tue, 10 Jun 2025 14:57:07 -0400 Subject: [PATCH 3/6] update docker compose --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9a614f2..343e264 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,9 @@ -x-rust-image: &rust-image rust:alpine3.21 +x-rust-image: &rust-image mira-oxide/rust-nightly x-data-volume: &data-volume type: bind source: /home/xpa3/mira-oxide/test - target: /mira-oxide/data + target: /data services: mira-oxide: From 55e18fb8286f1d35a8d34097072e5441092b9969 Mon Sep 17 00:00:00 2001 From: Samuel Shepard Date: Tue, 17 Jun 2025 12:24:17 -0400 Subject: [PATCH 4/6] Strip images to keep them small --- Cargo.toml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a2bb410..603fea6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,10 @@ [workspace] -members = [ "all_sample_hamming_dist", "all_sample_nt_diffs", - "mutations_of_interest_table", "plots", +members = [ + "all_sample_hamming_dist", + "all_sample_nt_diffs", + "mutations_of_interest_table", + "plots", ] [workspace.dependencies] @@ -12,3 +15,6 @@ serde = { version = "1.0.219", features = ["derive"] } zoe = { git = "https://github.com/CDCgov/zoe.git", tag = "v0.0.18", default-features = false, features = [ "multiversion", ] } + +[profile.release] +strip = true From b692d360cdffb758601aa2f7e1c9323aae61ab51 Mon Sep 17 00:00:00 2001 From: Samuel Shepard Date: Tue, 17 Jun 2025 12:24:34 -0400 Subject: [PATCH 5/6] Use multi-stage build with latest nightly alpine image --- Dockerfile | 64 +++++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d7b726..4857888 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ # Create an argument to pull a particular version of an image -ARG rust_image -ARG rust_image=${rust_image:-rust:alpine3.21} #################################################################################################### # BASE IMAGE #################################################################################################### -FROM ${rust_image} AS base +FROM rustlang/rust:nightly-alpine AS builder + # Required certs for apk update COPY ca.crt /root/ca.crt @@ -13,20 +12,10 @@ COPY ca.crt /root/ca.crt # Put certs in /etc/ssl/certs location RUN cat /root/ca.crt >> /etc/ssl/certs/ca-certificates.crt -# Install system libraries of general use -RUN apk update && apk add --no-cache \ - bash \ - vim \ - tar \ - dos2unix \ - build-base - -##update to rust nightly -RUN rustup toolchain install nightly +RUN apk update && apk add --no-cache build-base -RUN rustup override set nightly -############# Copy everything into conatiner then build ################## +WORKDIR /app # Copy all scripts to docker images COPY . . @@ -34,39 +23,30 @@ COPY . . # This build step will cache the dependencies RUN cargo build --release -RUN rm -rf /var/lib/{apt,dpkg,cache,log}/ \ - /target/debug \ - /git* - -############# Fix vulnerablities pkgs ################## - -# Convert bash script from Windows style line endings to Unix-like control characters -#RUN dos2unix ${PROJECT_DIR}/fixed_vulnerability_pkgs.sh - -# Allow permission to excute the bash script -#RUN chmod a+x ${PROJECT_DIR}/fixed_vulnerability_pkgs.sh -# Execute bash script to wget the file and tar the package -#RUN bash ${PROJECT_DIR}/fixed_vulnerability_pkgs.sh +FROM alpine:latest as deploy -############# Remove vulnerability pkgs ################## - -# Copy all files to docker images -#COPY docker_files/remove_vulnerability_pkgs.txt ${PROJECT_DIR}/remove_vulnerability_pkgs.txt +# May only be required for WSL. +# Required certs for apk update +COPY ca.crt /root/ca.crt -# Copy all files to docker images -#COPY docker_files/remove_vulnerability_pkgs.sh ${PROJECT_DIR}/remove_vulnerability_pkgs.sh +# Put certs in /etc/ssl/certs location +RUN cat /root/ca.crt >> /etc/ssl/certs/ca-certificates.crt -# Convert bash script from Windows style line endings to Unix-like control characters -#RUN dos2unix ${PROJECT_DIR}/remove_vulnerability_pkgs.sh +# Install system libraries of general use +RUN apk update && apk add --no-cache \ + bash \ + && rm -rf /var/lib/{apt,dpkg,cache,log} \ + && rm /root/ca.crt -# Allow permission to excute the bash script -#RUN chmod a+x ${PROJECT_DIR}/remove_vulnerability_pkgs.sh +WORKDIR /app -# Execute bash script to wget the file and tar the package -#RUN bash ${PROJECT_DIR}/remove_vulnerability_pkgs.sh +COPY --from=builder \ + /app/target/release/mutations_of_interest_table \ + /app/target/release/all_sample_nt_diffs \ + /app/target/release/all_sample_hamming_dist \ + /app/target/release/plots /app/ -############# Set up working directory ################## # Create working directory variable ENV WORKDIR=/data @@ -78,4 +58,4 @@ VOLUME ${WORKDIR} WORKDIR ${WORKDIR} # Export project directory to PATH -ENV PATH "$PATH:/target/release" +ENV PATH "$PATH:/app" From 9efe6ebb90cc35f2854790cfae5e821b81c8c16f Mon Sep 17 00:00:00 2001 From: mandysulli Date: Tue, 24 Jun 2025 13:24:18 -0400 Subject: [PATCH 6/6] add check_chemistry --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4857888..07bf6c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,8 +45,8 @@ COPY --from=builder \ /app/target/release/mutations_of_interest_table \ /app/target/release/all_sample_nt_diffs \ /app/target/release/all_sample_hamming_dist \ - /app/target/release/plots /app/ - + /app/target/release/plots \ + /app/target/release/check_chemistry /app/ # Create working directory variable ENV WORKDIR=/data