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/.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 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..053a11b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + wayback_machine_downloader: + build: + context: . + tty: true + image: wayback_machine_downloader:latest + container_name: wayback_machine_downloader + environment: + - ENVIRONMENT=${ENVIRONMENT} + volumes: + - .:/build:rw + - ./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