From acec026ce13251436af7aded28b7556bf3d8905b Mon Sep 17 00:00:00 2001 From: adampweb Date: Sun, 6 Apr 2025 12:36:31 +0200 Subject: [PATCH 1/3] Using Docker Compose --- .dockerignore | 5 +++++ README.md | 17 +++++++++++++++++ docker-compose.yml | 10 ++++++++++ 3 files changed, 32 insertions(+) create mode 100644 .dockerignore create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c0bee63 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +*.md +*.yml + +.github +websites \ No newline at end of file diff --git a/README.md b/README.md index 953f517..bf9c8e2 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,23 @@ docker build -t wayback_machine_downloader . docker run -it --rm wayback_machine_downloader [options] URL ``` +### 🐳 Using Docker Compose + +We can also use it with Docker Compose, which provides a lot of benefits for extending more functionalities (such as implementing storing previous downloads in a database): +```yaml +# docker-compose.yml +services: + wayback_machine_downloader: + build: + context: . + tty: true + image: wayback_machine_downloader:latest + container_name: wayback_machine_downloader + volumes: + - .:/build:rw + - ./websites:/build/websites:rw +``` + ## ⚙️ Configuration There are a few constants that can be edited in the `wayback_machine_downloader.rb` file for your convenience. The default values may be conservative, so you can adjust them to your needs. They are: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c7af014 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + wayback_machine_downloader: + build: + context: . + tty: true + image: wayback_machine_downloader:latest + container_name: wayback_machine_downloader + volumes: + - .:/build:rw + - ./websites:/build/websites:rw \ No newline at end of file From b1080f021952822e421400aee5d279e9def68865 Mon Sep 17 00:00:00 2001 From: adampweb Date: Sun, 6 Apr 2025 16:56:59 +0200 Subject: [PATCH 2/3] Keep secrets :) --- .env.example | 4 ++++ .gitignore | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..67f703a --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +DB_HOST="db" +DB_USER="root" +DB_PASSWORD="example1234" +DB_NAME="wayback" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6c6f892..7f5ff26 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,11 @@ Gemfile.lock .ruby-version .rbenv* +## ENV +*.env* +!.env*.example + + ## RCOV coverage.data From 5aebf83fca15c9b689fe9317d894e15c006bb049 Mon Sep 17 00:00:00 2001 From: adampweb Date: Sun, 6 Apr 2025 17:02:39 +0200 Subject: [PATCH 3/3] Add interactivity by CLI --- docker-compose.yml | 5 ++++- entrypoint.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 entrypoint.sh diff --git a/docker-compose.yml b/docker-compose.yml index c7af014..053a11b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,9 @@ services: tty: true image: wayback_machine_downloader:latest container_name: wayback_machine_downloader + environment: + - ENVIRONMENT=${ENVIRONMENT} volumes: - .:/build:rw - - ./websites:/build/websites:rw \ No newline at end of file + - ./websites:/build/websites:rw + command: --directory /build/websites ${OPTIONS} ${TARGET_URL} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..bfbc4fc --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ "$ENVIRONMENT" == "development" ]; then + echo "Running in development mode. Starting rerun..." + exec rerun --dir /build --ignore "websites/*" -- /build/bin/wayback_machine_downloader "$@" +else + echo "Not in development mode. Skipping rerun." + exec /build/bin/wayback_machine_downloader "$@" +fi \ No newline at end of file