|
|
||
|---|---|---|
| output | ||
| .gitignore | ||
| Dockerfile | ||
| README.md | ||
| build.sh | ||
| config.py | ||
| countfiles.py | ||
| cron_launch.sh | ||
| db_utils.py | ||
| docker-compose.yml | ||
| email_utils.py | ||
| error_handler.py | ||
| file_utils.py | ||
| logging_config.py | ||
| main.py | ||
| query-sql.md | ||
| requirements.txt | ||
| s3_utils.py | ||
| utils.py | ||
| validation_utils.py | ||
README.md
Project Setup
Setting up a Virtual Environment
-
Create a virtual environment:
For Linux/macOS:
python3 -m venv .venvFor Windows:
## ACH-server-import-media This repository contains a script to import media files from an S3-compatible bucket into a database. It supports both local execution (virtual environment) and Docker-based deployment via `docker-compose`. Contents - `main.py` - main import script - `docker-compose.yml` - docker-compose service for running the importer in a container - `requirements.txt` - Python dependencies - `config.py`, `.env` - configuration and environment variables Prerequisites - Docker & Docker Compose (or Docker Desktop) - Python 3.8+ - Git (optional) Quick local setup (virtual environment) Linux / macOS ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txtWindows (PowerShell)
python -m venv .venv . .venv\Scripts\Activate.ps1 pip install -r requirements.txtRunning locally
- Ensure your configuration is available (see
config.pyor provide a.envfile with the environment variables used by the project). - Run the script (from the project root):
Linux / macOS
python main.pyWindows (PowerShell)
& .venv\Scripts\python.exe main.pyDocker Compose
This project includes a
docker-compose.ymlwith a service namedapp(container nameACH_server_media_importer). The compose file reads environment variables from.envand mounts alogsnamed volume.Build and run (detached)
# Docker Compose v2 syntax (recommended) # From the repository root docker compose up -d --build # OR if your environment uses the v1 binary # docker-compose up -d --buildShow logs
# Follow logs for the 'app' service docker compose logs -f app # Or use the container name docker logs -f ACH_server_media_importerStop / start / down
# Stop containers docker compose stop # Start again docker compose start # Take down containers and network docker compose downRebuild when already running
There are two safe, common ways to rebuild a service when the containers are already running:
- Rebuild in-place and recreate changed containers (recommended for most changes):
# Rebuild images and recreate services in the background docker compose up -d --buildThis tells Compose to rebuild the image(s) and recreate containers for services whose image or configuration changed.
- Full clean rebuild (use when you need to remove volumes or ensure a clean state):
# Stop and remove containers, networks, and optionally volumes & images, then rebuild docker compose down --volumes --rmi local docker compose up -d --buildNotes
docker compose up -d --buildwill recreate containers for services that need updating; it does not destroy named volumes unless you pass--volumestodown.- If you need to execute a shell inside the running container:
# run a shell inside the 'app' service docker compose exec app /bin/sh # or (if bash is available) docker compose exec app /bin/bashEnvironment and configuration
- Provide sensitive values via a
.envfile (thedocker-compose.ymlalready references.env). - Typical variables:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION,BUCKET_NAME,DB_HOST,DB_NAME,DB_USER,SMTP_SERVER, etc.
Troubleshooting
- If Compose fails to pick up code changes, ensure your local Dockerfile
COPYcommands include the source files and thatdocker compose up -d --buildis run from the repository root. - Use
docker compose logs -f appto inspect runtime errors.
If you'd like, I can add a short
Makefileor a PowerShell script to wrap the common Docker Compose commands (build, rebuild, logs) for convenience.
Edited to add clear docker-compose rebuild and run instructions.
- Ensure your configuration is available (see