Skip to content

Commit

Permalink
TG-940 Add local MinIO service
Browse files Browse the repository at this point in the history
  • Loading branch information
niccolomineo committed Jan 23, 2024
1 parent db6c436 commit dcd4d7d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
6 changes: 6 additions & 0 deletions bootstrap/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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,
Expand Down
48 changes: 43 additions & 5 deletions {{cookiecutter.project_dirname}}/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:latest
ports:
- 9000:9000
- 9001:9001
volumes:
- minio_data:/var/lib/minio/data
networks:
custom:
ipv4_address: 172.20.0.13{% 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 %}

0 comments on commit dcd4d7d

Please sign in to comment.