Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__
!.env.e2e
!.env.e2e-tests
!.env.fuzz-tests
!.env.localstack
!.env.unit-tests
.github/instructions/snyk_rules.instructions.md
.idea
Expand Down
3 changes: 0 additions & 3 deletions docker-compose/infrastructure/compose.deploy.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions docker-compose/infrastructure/compose.integration.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions docker-compose/infrastructure/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
networks:
- infrastructure-nest
ports:
- 443:443
- 4510-4559:4510-4559
- 4566:4566
volumes:
Expand All @@ -29,11 +30,22 @@ services:
environment:
LOCALSTACK_AUTH_TOKEN: ${LOCALSTACK_AUTH_TOKEN}
LOCALSTACK_HOST: localhost
group_add:
# Grant access to the mounted docker socket. Its in-container GID varies:
# Linux exposes the host docker group's GID; macOS runtimes (Docker Desktop,
# OrbStack, colima, etc) proxy the socket through a Linux VM and it typically
# shows up as root:root inside the container.
- '0'
- ${DOCKER_GID}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When this Compose file is run without the Make target, an unset DOCKER_GID becomes an empty group ID and the runner fails before deployment. Default the value to 0 or fail with an explicit required-variable check.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docker-compose/infrastructure/compose.yaml, line 39:

<comment>When this Compose file is run without the Make target, an unset `DOCKER_GID` becomes an empty group ID and the runner fails before deployment. Default the value to `0` or fail with an explicit required-variable check.</comment>

<file context>
@@ -29,11 +30,22 @@ services:
+      # OrbStack, colima, etc) proxy the socket through a Linux VM and it typically
+      # shows up as root:root inside the container.
+      - '0'
+      - ${DOCKER_GID}
     image: nest-infrastructure
     network_mode: service:localstack
</file context>
Suggested change
- ${DOCKER_GID}
- ${DOCKER_GID:-0}

image: nest-infrastructure
network_mode: service:localstack
pull_policy: never
volumes:
- infrastructure-terraform-plugin-cache:/home/owasp/.terraform.d/plugin-cache
# Host Docker socket so runner can build containers (Backend, Frontend, etc.).
- /var/run/docker.sock:/var/run/docker.sock
# Host repo as docker build context for backend/frontend images.
- ../..:/repo:ro

networks:
infrastructure-nest:
Expand Down
6 changes: 6 additions & 0 deletions docker/infrastructure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
ARG OWASP_GID
ARG OWASP_UID

RUN apk --no-cache add docker-cli docker-cli-buildx

Check warning on line 47 in docker/infrastructure/Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this RUN instruction with the consecutive ones.

See more on https://sonarcloud.io/project/issues?id=OWASP_Nest&issues=AaAvboigObA3UIzK0opx&open=AaAvboigObA3UIzK0opx&pullRequest=5463

RUN addgroup -S -g ${OWASP_GID} owasp && \
adduser -S -h /home/owasp -u ${OWASP_UID} -G owasp owasp && \
mkdir -p \
Expand All @@ -70,6 +72,10 @@
COPY --from=terraform --chmod=555 --chown=root:root /bin/terraform /usr/local/bin/terraform
COPY --from=builder --chown=owasp:owasp /home/owasp /home/owasp

# Infrastructure sources are copied (not mounted) so tflocal can write .terraform/
# and LocalStack override files inside the container without polluting the host.
# A read-only mount would fail those writes and a read-write mount would leak them
# to the host. Copying keeps writes scoped to the container lifetime.
COPY --chown=owasp:owasp infrastructure/bootstrap /home/owasp/infrastructure/bootstrap
COPY --chown=owasp:owasp infrastructure/live /home/owasp/infrastructure/live
COPY --chown=owasp:owasp infrastructure/modules /home/owasp/infrastructure/modules
Expand Down
2 changes: 1 addition & 1 deletion docker/localstack/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM localstack/localstack:2026.7.1@sha256:bdc261f58767dda5385800cfcefae7e8036f91428f26117b29c4572a7a9bbdc9
FROM localstack/localstack:2026.7.4@sha256:f7b778d03717b58c3adce81a740bfafff5c6f9d639159bbf08da557c9ac1b513
11 changes: 11 additions & 0 deletions frontend/.env.localstack
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NEXT_PUBLIC_API_URL=/
NEXT_PUBLIC_CSRF_URL=/csrf/
NEXT_PUBLIC_ENVIRONMENT=production
NEXT_PUBLIC_GRAPHQL_URL=/graphql/
NEXT_PUBLIC_GTM_ID=
NEXT_PUBLIC_IDX_URL=/idx/
NEXT_PUBLIC_IS_PROJECT_HEALTH_ENABLED=true
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
NEXT_PUBLIC_POSTHOG_KEY=
NEXT_PUBLIC_RELEASE_VERSION=
NEXT_PUBLIC_SENTRY_DSN=
2 changes: 2 additions & 0 deletions infrastructure/live/terraform.localstack.tfbackend.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bucket = "nest-localstack-terraform-state"
endpoints = { s3 = "http://localstack:4566" }
key = "localstack/terraform.tfstate"
region = "us-east-1"
use_path_style = true
24 changes: 16 additions & 8 deletions infrastructure/make/run.mk
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
.PHONY: infrastructure-up
.PHONY: infrastructure-check-auth-token infrastructure-refresh infrastructure-up

DOCKER_GID := $(shell stat -c '%g' /var/run/docker.sock 2>/dev/null || stat -f '%g' /var/run/docker.sock)
export DOCKER_GID

INFRASTRUCTURE_COMPOSE = docker compose \
--project-name nest-infrastructure \
-f docker-compose/infrastructure/compose.yaml

infrastructure-up: ## Start LocalStack and deploy infrastructure
infrastructure-check-auth-token:
@if [ -z "$$LOCALSTACK_AUTH_TOKEN" ]; then \
if [ -t 2 ]; then \
printf '\033[1;31mError:\033[0m LOCALSTACK_AUTH_TOKEN is not set.\n' >&2; \
else \
echo "Error: LOCALSTACK_AUTH_TOKEN is not set." >&2; \
fi; \
exit 1; \
fi; \
$(MAKE) infrastructure-image-build || exit $$?; \
COMPOSE_BAKE=true DOCKER_BUILDKIT=1 \
$(INFRASTRUCTURE_COMPOSE) \
-f docker-compose/infrastructure/compose.deploy.yaml \
up
fi

infrastructure-refresh: infrastructure-check-auth-token ## Refresh an existing deployment on LocalStack
@$(MAKE) infrastructure-image-build || exit $$?; \
$(INFRASTRUCTURE_COMPOSE) up --wait localstack || exit $$?; \
$(INFRASTRUCTURE_COMPOSE) run --rm runner python -m scripts.run_deploy --refresh

infrastructure-up: infrastructure-check-auth-token ## Start LocalStack and deploy infrastructure
@$(MAKE) infrastructure-image-build || exit $$?; \
$(INFRASTRUCTURE_COMPOSE) up --wait localstack || exit $$?; \
$(INFRASTRUCTURE_COMPOSE) run --rm runner python -m scripts.run_deploy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: When the deployment runner exits non-zero, make infrastructure-up now fails even though LocalStack remains available. Preserve this target's plain-Compose lifecycle and do not propagate the runner exit status; rely on the runner logs instead.

(Based on your team's feedback about preserving the LocalStack deployment lifecycle.) [0389fa83-4d4f-455a-a265-8d983703c932]

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At infrastructure/make/run.mk, line 28:

<comment>When the deployment runner exits non-zero, `make infrastructure-up` now fails even though LocalStack remains available. Preserve this target's plain-Compose lifecycle and do not propagate the runner exit status; rely on the runner logs instead.

(Based on your team's feedback about preserving the LocalStack deployment lifecycle.) [0389fa83-4d4f-455a-a265-8d983703c932]</comment>

<file context>
@@ -1,20 +1,28 @@
+infrastructure-up: infrastructure-check-auth-token ## Start LocalStack and deploy infrastructure
+	@$(MAKE) infrastructure-image-build || exit $$?; \
+	$(INFRASTRUCTURE_COMPOSE) up --wait localstack || exit $$?; \
+	$(INFRASTRUCTURE_COMPOSE) run --rm runner python -m scripts.run_deploy
</file context>
Suggested change
$(INFRASTRUCTURE_COMPOSE) run --rm runner python -m scripts.run_deploy
$(INFRASTRUCTURE_COMPOSE) run --rm runner python -m scripts.run_deploy || true

10 changes: 2 additions & 8 deletions infrastructure/make/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ infrastructure-test-integration:
$(MAKE) infrastructure-image-build || exit $$?; \
status=0; \
trap '$(INFRASTRUCTURE_COMPOSE) down --remove-orphans >/dev/null 2>&1 || true' EXIT; \
COMPOSE_BAKE=true DOCKER_BUILDKIT=1 \
$(INFRASTRUCTURE_COMPOSE) \
-f docker-compose/infrastructure/compose.integration.yaml \
up \
--abort-on-container-exit \
--build \
--exit-code-from runner \
|| status=$$?; \
$(INFRASTRUCTURE_COMPOSE) up --wait localstack || exit $$?; \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When a developer already has the Compose LocalStack image, this target can run integration tests against a stale pinned version because up does not force a rebuild. Pass --build when starting localstack so Dockerfile changes are applied.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At infrastructure/make/test.mk, line 47:

<comment>When a developer already has the Compose LocalStack image, this target can run integration tests against a stale pinned version because `up` does not force a rebuild. Pass `--build` when starting `localstack` so Dockerfile changes are applied.</comment>

<file context>
@@ -44,12 +44,6 @@ infrastructure-test-integration:
-			--build \
-			--exit-code-from runner \
-		|| status=$$?; \
+	$(INFRASTRUCTURE_COMPOSE) up --wait localstack || exit $$?; \
+	$(INFRASTRUCTURE_COMPOSE) run --rm runner python -m scripts.run_tests --integration || status=$$?; \
 	exit $$status
</file context>

$(INFRASTRUCTURE_COMPOSE) run --rm runner python -m scripts.run_tests --integration || status=$$?; \
exit $$status
Loading
Loading