Skip to content

Commit d03f68d

Browse files
committed
fix(release): make the production Docker build and deploy work
Two splent-migration leftovers broke the tagged-release pipeline: - app/features/webhook/services.py created `docker.from_env()` at module import. The rosemary CLI imports every command (and thus the app) while running `rosemary webpack:compile` during `docker build`, where there is no Docker daemon, so the release image failed to build. The client is now created lazily on first use. - rosemary selenium/locust commands still branched on the old WORKING_DIR "/app/" (and a "/app" mount destination); updated to "/workspace" to match the splent layout, so those commands work inside the new containers. Verified: the rosemary CLI now loads with no Docker daemon (37 commands) and `docker build -f docker/images/Dockerfile.prod` succeeds end to end (webpack:compile runs for every feature; image builds).
1 parent b88a1c0 commit d03f68d

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

app/features/webhook/services.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@
88

99
import docker
1010

11-
client = docker.from_env()
11+
_client = None
12+
13+
14+
def _get_client():
15+
"""Lazily build the Docker client on first use, not at import time.
16+
17+
Importing this module must not require a Docker daemon: the rosemary CLI
18+
imports every command module (which pulls in the app, and therefore this
19+
service) while running 'rosemary webpack:compile' during 'docker build',
20+
where no daemon exists. Connecting at import broke the release image build.
21+
"""
22+
global _client
23+
if _client is None:
24+
_client = docker.from_env()
25+
return _client
26+
1227

1328
# Commands run inside every target container, in order, on each deploy.
1429
DEPLOY_COMMANDS = (
@@ -31,13 +46,13 @@ def is_authorized(self, auth_header: str | None) -> bool:
3146

3247
def get_web_container(self):
3348
try:
34-
return client.containers.get("web_app_container")
49+
return _get_client().containers.get("web_app_container")
3550
except docker.errors.NotFound:
3651
abort(404, description="Web container not found.")
3752

3853
def get_worker_container(self):
3954
try:
40-
return client.containers.get("rq_worker_container")
55+
return _get_client().containers.get("rq_worker_container")
4156
except docker.errors.NotFound:
4257
abort(404, description="Worker container not found.")
4358

rosemary/src/rosemary/commands/locust.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def run_vagrant_locust(module):
123123
if module:
124124
validate_module(module)
125125

126-
if working_dir == "/app/":
126+
if working_dir == "/workspace/":
127127
client = docker.from_env()
128128

129129
try:
@@ -132,7 +132,7 @@ def run_vagrant_locust(module):
132132
(
133133
mount.get("Name") or mount.get("Source")
134134
for mount in web_container.attrs["Mounts"]
135-
if mount["Destination"] == "/app"
135+
if mount["Destination"] == "/workspace"
136136
),
137137
None,
138138
)
@@ -180,7 +180,7 @@ def stop_docker_locust():
180180
# Remove the Locust container
181181
subprocess.run(rm_command)
182182

183-
if working_dir == "/app/":
183+
if working_dir == "/workspace/":
184184
stop_docker_locust()
185185

186186
elif working_dir == "" or working_dir == "/vagrant/":

rosemary/src/rosemary/commands/selenium.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def run_vagrant_tests(module_name):
8383
if module:
8484
validate_module(module)
8585

86-
if working_dir == "/app/":
86+
if working_dir == "/workspace/":
8787
run_selenium_tests(module, env="docker")
8888
elif working_dir == "":
8989
run_selenium_tests(module, env="local")

0 commit comments

Comments
 (0)