diff --git a/bootstrap/collector.py b/bootstrap/collector.py index 7e66eb0..e13d6a1 100755 --- a/bootstrap/collector.py +++ b/bootstrap/collector.py @@ -102,6 +102,7 @@ class Collector: pact_broker_username: str | None = None pact_broker_password: str | None = None media_storage: str | None = None + local_s3_storage: bool | None = None s3_region: str | None = None s3_host: str | None = None s3_access_id: str | None = None @@ -541,6 +542,10 @@ def set_storage(self): self.s3_secret_key = validate_or_prompt_secret( "S3 Secret Access Key", self.s3_secret_key ) + if self.local_s3_storage is None: + self.local_s3_storage = click.confirm( + warning("Do you want to use the local S3 storage?"), default=False + ) def set_digitalocean_spaces(self): """Set the DigitalOcean Spaces options.""" @@ -627,6 +632,7 @@ def get_runner(self): pact_broker_username=self.pact_broker_username, pact_broker_password=self.pact_broker_password, media_storage=self.media_storage, + local_s3_storage=self.local_s3_storage, s3_region=self.s3_region, s3_host=self.s3_host, s3_access_id=self.s3_access_id, diff --git a/{{cookiecutter.project_dirname}}/docker-compose.yaml b/{{cookiecutter.project_dirname}}/docker-compose.yaml index 159a14c..fb9d2b1 100644 --- a/{{cookiecutter.project_dirname}}/docker-compose.yaml +++ b/{{cookiecutter.project_dirname}}/docker-compose.yaml @@ -10,12 +10,15 @@ services: target: ${BACKEND_BUILD_TARGET:-local} depends_on: postgres: - condition: service_healthy + condition: service_healthy{% if cookiecutter.local_s3_storage == "true" %} + minio: + condition: service_healthy{% endif %} environment: - CACHE_URL - DATABASE_URL - DJANGO_ADMINS - - DJANGO_ALLOWED_HOSTS + - DJANGO_ALLOWED_HOSTS{% if "s3" in cookiecutter.media_storage %} + - DJANGO_AWS_S3_URL{% endif %} - DJANGO_CONFIGURATION - DJANGO_DEBUG - DJANGO_DEFAULT_FROM_EMAIL @@ -39,7 +42,10 @@ services: retries: 5 user: ${USER:-appuser} volumes: - - ./{{ cookiecutter.backend_service_slug }}:/app{% endif %} + - ./{{ cookiecutter.backend_service_slug }}:/app{% endif %}{% if cookiecutter.local_s3_storage == "true" %} + networks: + custom: + ipv4_address: 172.20.0.10{% endif %} {% if cookiecutter.frontend_type != "none" %} {{ cookiecutter.frontend_service_slug }}: build: @@ -97,7 +103,39 @@ services: retries: 30 image: postgres:14-bullseye volumes: - - pg_data:/var/lib/postgresql/data + - pg_data:/var/lib/postgresql/data{% if cookiecutter.local_s3_storage == "true" %} + networks: + custom: + ipv4_address: 172.20.0.11 + + minio: + command: minio server /var/lib/minio/data --console-address ":9001" + environment: + - MINIO_ENDPOINT=http://minio:9000 + - MINIO_BUCKET_NAME={{ cookiecutter.project_slug }} + - MINIO_ROOT_USER=minio-admin + - MINIO_ROOT_PASSWORD=minio-admin + healthcheck: + test: ["CMD", "mc", "ready", "local"] + interval: 3s + timeout: 3s + retries: 30 + image: minio/minio:RELEASE.2024-01-31T20-20-33Z + ports: + - 9000:9000 + - 9001:9001 + volumes: + - minio_data:/var/lib/minio/data + networks: + custom: + ipv4_address: 172.20.0.12{% endif %} volumes: - pg_data: {} + pg_data: {}{% if cookiecutter.local_s3_storage == "true" %} + minio_data: {} + +networks: + custom: + ipam: + config: + - subnet: 172.20.0.0/16{% endif %}