diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 0000000000..47241b6ef0 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1 @@ +images/ diff --git a/docker/justfile b/docker/justfile new file mode 100644 index 0000000000..19ffacb447 --- /dev/null +++ b/docker/justfile @@ -0,0 +1,39 @@ +set dotenv-load := false + +COLOR := "\\033[0;35m" +NO_COLOR := "\\033[0m" + +# Show all available recipes +@_default: + printf "\n{{ COLOR }}# Docker (path: \`docker/\`)\n" + printf "=========================={{ NO_COLOR }}\n" + just --list --unsorted + +################ +# Offline mode # +################ + +# Save all Docker images needed for all services +save: + #!/usr/bin/env bash + mkdir -p images/; + git grep "image:" \ + | grep "compose.yml" \ + | grep --invert-match "openverse" \ + | awk 'NF>1{print $NF}' \ + | while read line; do + name="docker/images/"$(echo $line | sed 's:/:-:g')".tar.gz"; + echo "Exporting image $line to file $name"; + docker image pull --quiet $line; + docker image save $line | gzip > $name; + done + +# Load all images saved in the `images/` dir +load: + #!/usr/bin/env bash + ls images/ \ + | while read line; do + name="images/"$line; + echo "Importing image from $name"; + docker image load < $name; + done diff --git a/justfile b/justfile index 103400c20b..d262046cf6 100644 --- a/justfile +++ b/justfile @@ -14,6 +14,7 @@ DC_USER := env_var_or_default("DC_USER", "opener") @_default: just --list --unsorted cd packages/python/openverse-attribution && just + cd docker/ && just cd docker/cache && just cd docker/nginx && just cd docker/es && just @@ -146,6 +147,15 @@ lint-codeowners checks="stable": ([ ! -f ingestion_server/.env ] && cp ingestion_server/env.template ingestion_server/.env) || true ([ ! -f api/.env ] && cp api/env.template api/.env) || true +# Delete `.env` files +unenv: + rm \ + .env \ + docker/minio/.env \ + catalog/.env \ + ingestion_server/.env \ + api/.env + ########## # Docker # ##########