Skip to content

Commit cb2a0e9

Browse files
authored
set s3 endpoint based on wsl2 ip address (#2047)
* set s3 endpoint based on wsl2 ip address * missing : * now works perfectly with wsl2
1 parent 0d1ba68 commit cb2a0e9

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

Makefile

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ MAKE_C := $(MAKE) --no-print-directory --directory
1717
# Operating system
1818
ifeq ($(filter Windows_NT,$(OS)),)
1919
IS_WSL := $(if $(findstring Microsoft,$(shell uname -a)),WSL,)
20+
IS_WSL2 := $(if $(findstring -microsoft-,$(shell uname -a)),WSL2,)
2021
IS_OSX := $(filter Darwin,$(shell uname -a))
2122
IS_LINUX:= $(if $(or $(IS_WSL),$(IS_OSX)),,$(filter Linux,$(shell uname -a)))
2223
endif
2324

2425
IS_WIN := $(strip $(if $(or $(IS_LINUX),$(IS_OSX),$(IS_WSL)),,$(OS)))
2526
$(if $(IS_WIN),$(error Windows is not supported in all recipes. Use WSL instead. Follow instructions in README.md),)
2627

27-
2828
# VARIABLES ----------------------------------------------
2929
# TODO: read from docker-compose file instead $(shell find $(CURDIR)/services -type f -name 'Dockerfile')
3030
# or $(notdir $(subst /Dockerfile,,$(wildcard services/*/Dockerfile))) ...
@@ -71,6 +71,12 @@ export ETC_HOSTNAME
7171
host := $(shell echo $$(hostname) > $(ETC_HOSTNAME))
7272
endif
7373

74+
# NOTE: this is only for WSL2 as the WSL2 subsystem IP is changing on each reboot
75+
ifeq ($(IS_WSL2),WSL2)
76+
S3_ENDPOINT = $(shell hostname --all-ip-addresses | cut --delimiter=" " --fields=1):9001
77+
export S3_ENDPOINT
78+
endif
79+
7480

7581
.PHONY: help
7682

@@ -204,34 +210,44 @@ else
204210
@echo "Explicitly disabled with ops_disabled flag in CLI"
205211
endif
206212

213+
define _show_endpoints
214+
# The following endpoints are available
215+
echo "http://$(if $(IS_WSL2),$(get_my_ip),127.0.0.1):9081 - oSparc platform"
216+
echo "http://$(if $(IS_WSL2),$(get_my_ip),127.0.0.1):18080/?pgsql=postgres&username=scu&db=simcoredb&ns=public - Postgres DB"
217+
echo "http://$(if $(IS_WSL2),$(get_my_ip),127.0.0.1):9000 - Portainer"
218+
endef
207219

208220
up-devel: .stack-simcore-development.yml .init-swarm $(CLIENT_WEB_OUTPUT) ## Deploys local development stack, qx-compile+watch and ops stack (pass 'make ops_disabled=1 up-...' to disable)
209221
# Start compile+watch front-end container [front-end]
210-
$(MAKE_C) services/web/client down compile-dev flags=--watch
222+
@$(MAKE_C) services/web/client down compile-dev flags=--watch
211223
# Deploy stack $(SWARM_STACK_NAME) [back-end]
212224
@docker stack deploy --with-registry-auth -c $< $(SWARM_STACK_NAME)
213-
$(MAKE) .deploy-ops
214-
$(MAKE_C) services/web/client follow-dev-logs
225+
@$(MAKE) .deploy-ops
226+
@$(_show_endpoints)
227+
@$(MAKE_C) services/web/client follow-dev-logs
215228

216229

217230
up-prod: .stack-simcore-production.yml .init-swarm ## Deploys local production stack and ops stack (pass 'make ops_disabled=1 up-...' to disable or target=<service-name> to deploy a single service)
218231
ifeq ($(target),)
219232
# Deploy stack $(SWARM_STACK_NAME)
220233
@docker stack deploy --with-registry-auth -c $< $(SWARM_STACK_NAME)
221-
$(MAKE) .deploy-ops
234+
@$(MAKE) .deploy-ops
222235
else
223236
# deploys ONLY $(target) service
224-
docker-compose -f $< up --detach $(target)
237+
@docker-compose -f $< up --detach $(target)
238+
@$(_show_endpoints)
225239
endif
226240

227241
up-version: .stack-simcore-version.yml .init-swarm ## Deploys versioned stack '$(DOCKER_REGISTRY)/{service}:$(DOCKER_IMAGE_TAG)' and ops stack (pass 'make ops_disabled=1 up-...' to disable)
228242
# Deploy stack $(SWARM_STACK_NAME)
229243
@docker stack deploy --with-registry-auth -c $< $(SWARM_STACK_NAME)
230-
$(MAKE) .deploy-ops
244+
@$(MAKE) .deploy-ops
245+
@$(_show_endpoints)
231246

232247
up-latest:
233248
@export DOCKER_IMAGE_TAG=latest; \
234249
$(MAKE) up-version
250+
@$(_show_endpoints)
235251

236252

237253
.PHONY: down leave
@@ -471,7 +487,7 @@ local-registry: .env ## creates a local docker registry and configure simcore to
471487
.PHONY: info info-images info-swarm info-tools
472488
info: ## displays setup information
473489
# setup info:
474-
@echo ' Detected OS : $(IS_LINUX)$(IS_OSX)$(IS_WSL)$(IS_WIN)'
490+
@echo ' Detected OS : $(IS_LINUX)$(IS_OSX)$(IS_WSL)$(IS_WSL2)$(IS_WIN)'
475491
@echo ' SWARM_STACK_NAME : ${SWARM_STACK_NAME}'
476492
@echo ' DOCKER_REGISTRY : $(DOCKER_REGISTRY)'
477493
@echo ' DOCKER_IMAGE_TAG : ${DOCKER_IMAGE_TAG}'

0 commit comments

Comments
 (0)