Skip to content

Commit eed4cdb

Browse files
committed
Support Podman
- add GATEWAY_HOST toggle for Podman/WSL2 routing - reduce Eureka server log levels - acme-order: listen on any IP - avoid leaving the container network for traffic to acme-cart - acme-shopping-react: fix infinite loading on product pages
1 parent 8286bd6 commit eed4cdb

9 files changed

Lines changed: 63 additions & 27 deletions

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text=auto
2+
*.sh text eol=lf

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,7 @@ hello-world/
6565
**/cypress/screenshots
6666

6767
# tanzu
68-
build-output
68+
build-output
69+
70+
# Local Compose overrides (e.g. GATEWAY_HOST for Podman)
71+
local-development/.env

apps/acme-order/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"AcmeOrder": {
55
"commandName": "Project",
66
"launchUrl": "order",
7-
"applicationUrl": "http://localhost:8086",
7+
"applicationUrl": "http://*:8086",
88
"environmentVariables": {
99
"ASPNETCORE_ENVIRONMENT": "Development"
1010
}

apps/acme-shopping-react/src/products/page.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ export default function ProductPage() {
1818

1919
const addToCartMutation = useAddToCart(userInfo?.userId);
2020

21-
if (isProductLoading || isUserLoading || userInfo == null) {
21+
if (isProductLoading || isUserLoading) {
2222
return <Loading />;
2323
}
2424

25-
// TODO: maybe we can refactor the Catalog Service to remove duplicate `data` tag
26-
if (isProductLoading || data?.data == null) {
27-
return null;
25+
// TODO: maybe we can refactor the Catalog Service to remove duplicate `data` tag
26+
if (data?.data == null) {
27+
return (
28+
<div className="p-8">
29+
<p id="product-not-found">Product not found or catalog unavailable.</p>
30+
</div>
31+
);
2832
}
2933

3034
const product = data.data;

apps/acme-shopping-react/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import react from "@vitejs/plugin-react";
55
export default defineConfig({
66
plugins: [react()],
77
server: {
8-
allowedHosts: ["host.docker.internal"],
8+
allowedHosts: ["host.containers.internal","host.docker.internal"]
99
},
1010
});

local-development/.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copy to ".env" in this directory (Compose loads it automatically). Do not commit ".env".
2+
#
3+
# Podman / some Linux setups: use the hostname that resolves to your host from containers.
4+
# GATEWAY_HOST=host.containers.internal
5+
#
6+
# Note for Windows/WSL2 users: host.containers.internal may not resolve to your Windows host.
7+
# If you see 'connection refused' errors and the apps are running, try your WSL vEthernet adapter IP instead (e.g., 172.24.240.1).
8+
# GATEWAY_HOST=172.24.240.1

local-development/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ cd local-development
1818
docker compose -p acme-fitness up -d
1919
```
2020

21+
### Configure gateway routes to services running on host
22+
23+
[`spring-enterprise/routes.yml`](spring-enterprise/routes.yml) builds upstream URIs with `${GATEWAY_HOST:host.docker.internal}` as the hostname. Compose passes `GATEWAY_HOST` into the gateway container (default `host.docker.internal`). For **Podman** (or when that hostname misbehaves), set `GATEWAY_HOST` to a value that will work on your machine before running `compose up`:
24+
25+
```shell
26+
# Option 1: Copy [.env.example](.env.example) to **`local-development/.env`** and uncomment the line (Compose loads `.env` from this directory).
27+
# Option 2: Set the env var with your preferred shell
28+
# bash
29+
export GATEWAY_HOST="host.containers.internal"
30+
# CMD
31+
set GATEWAY_HOST="host.containers.internal"
32+
# PowerShell
33+
$env:GATEWAY_HOST="host.containers.internal"
34+
```
35+
2136
### Boot up each of the local application following their README
2237

2338
- [acme-cart](../apps/acme-cart/README.md)

local-development/docker-compose.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ services:
22

33
discovery:
44
container_name: discovery-server
5-
image: steeltoeoss/eureka-server
5+
image: steeltoe.azurecr.io/eureka-server
66
ports:
77
- "8761:8761"
8+
environment:
9+
LOGGING_LEVEL_COM_NETFLIX_EUREKA: ERROR
810

911
config:
1012
container_name: config-server
11-
image: steeltoeoss/config-server
13+
image: steeltoe.azurecr.io/config-server
1214
ports:
1315
- "8888:8888"
1416
volumes:
@@ -23,6 +25,8 @@ services:
2325
ports:
2426
- "8090:8090"
2527
- "9000:9000"
28+
environment:
29+
GATEWAY_HOST: ${GATEWAY_HOST:-host.docker.internal}
2630
volumes:
2731
- ./spring-enterprise:/app
2832
working_dir: /app

local-development/spring-enterprise/routes.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ spring:
88
# ####################################################
99
# acme-assist
1010
# ####################################################
11-
- uri: http://host.docker.internal:8081
11+
- uri: "http://${GATEWAY_HOST:host.docker.internal}:8081"
1212
predicates:
1313
- Path=/ai/*
1414
- Method=POST
1515
filters:
1616
- StripPrefix=0
1717
tags:
1818
- assist-service
19-
- uri: http://host.docker.internal:8081
19+
- uri: "http://${GATEWAY_HOST:host.docker.internal}:8081"
2020
predicates:
2121
- Path=/ai/admin/*
2222
- Method=GET
@@ -28,7 +28,7 @@ spring:
2828
# ####################################################
2929
# acme-cart
3030
# ####################################################
31-
- uri: http://host.docker.internal:8085
31+
- uri: "http://cart:5000"
3232
predicates:
3333
- Path=/cart/item/add/{userId}
3434
- Method=POST
@@ -37,7 +37,7 @@ spring:
3737
- TokenRelay
3838
tags:
3939
- cart
40-
- uri: http://host.docker.internal:8085
40+
- uri: "http://cart:5000"
4141
predicates:
4242
- Path=/cart/item/modify/{userId}
4343
- Method=POST
@@ -46,7 +46,7 @@ spring:
4646
- TokenRelay
4747
tags:
4848
- cart
49-
- uri: http://host.docker.internal:8085
49+
- uri: "http://cart:5000"
5050
predicates:
5151
- Path=/cart/items/{userId}
5252
- Method=GET
@@ -55,7 +55,7 @@ spring:
5555
- TokenRelay
5656
tags:
5757
- cart
58-
- uri: http://host.docker.internal:8085
58+
- uri: "http://cart:5000"
5959
predicates:
6060
- Path=/cart/clear/{userId}
6161
- Method=GET
@@ -64,7 +64,7 @@ spring:
6464
- TokenRelay
6565
tags:
6666
- cart
67-
- uri: http://host.docker.internal:8085
67+
- uri: "http://cart:5000"
6868
predicates:
6969
- Path=/cart/total/{userId}
7070
- Method=GET
@@ -79,7 +79,7 @@ spring:
7979
# ####################################################
8080
- title: products-route
8181
description: /products endpoint
82-
uri: http://host.docker.internal:8082
82+
uri: "http://${GATEWAY_HOST:host.docker.internal}:8082"
8383
predicates:
8484
- Path=/products
8585
- Method=GET
@@ -90,7 +90,7 @@ spring:
9090
- catalog
9191
- title: products-id-route
9292
description: /products/id endpoint
93-
uri: http://host.docker.internal:8082
93+
uri: "http://${GATEWAY_HOST:host.docker.internal}:8082"
9494
predicates:
9595
- Path=/products/{id}
9696
- Method=GET
@@ -100,7 +100,7 @@ spring:
100100
- catalog
101101
- title: catalogliveness-route
102102
description: /products/id endpoint
103-
uri: http://host.docker.internal:8082
103+
uri: "http://${GATEWAY_HOST:host.docker.internal}:8082"
104104
predicates:
105105
- Path=/catalogliveness
106106
- Method=GET
@@ -111,7 +111,7 @@ spring:
111111
- catalog
112112
- title: catalogliveness-route
113113
description: /products/id endpoint
114-
uri: http://host.docker.internal:8082
114+
uri: "http://${GATEWAY_HOST:host.docker.internal}:8082"
115115
predicates:
116116
- Path=/static/images/{id}
117117
- Method=GET
@@ -125,7 +125,7 @@ spring:
125125
# ####################################################
126126
- order: 0
127127
ssoEnabled: true
128-
uri: http://host.docker.internal:8083
128+
uri: "http://${GATEWAY_HOST:host.docker.internal}:8083"
129129
predicates:
130130
- Path=/acme-login
131131
- Method=GET
@@ -134,7 +134,7 @@ spring:
134134
- RedirectTo=302, /
135135
tags:
136136
- sso
137-
- uri: http://host.docker.internal:8083
137+
- uri: "http://${GATEWAY_HOST:host.docker.internal}:8083"
138138
predicates:
139139
- Path=/userinfo
140140
- Method=GET
@@ -150,7 +150,7 @@ spring:
150150
- Method=POST
151151
tags:
152152
- users
153-
- uri: http://host.docker.internal:8083
153+
- uri: "http://${GATEWAY_HOST:host.docker.internal}:8083"
154154
predicates:
155155
- Path=/whoami
156156
- Method=GET
@@ -163,7 +163,7 @@ spring:
163163
# ####################################################
164164
# acme-order
165165
# ####################################################
166-
- uri: http://host.docker.internal:8086
166+
- uri: "http://${GATEWAY_HOST:host.docker.internal}:8086"
167167
title: Create an order.
168168
description: Creates an order for the user.
169169
predicates:
@@ -174,7 +174,7 @@ spring:
174174
- TokenRelay
175175
tags:
176176
- order
177-
- uri: http://host.docker.internal:8086
177+
- uri: "http://${GATEWAY_HOST:host.docker.internal}:8086"
178178
title: Retrieve User's Orders.
179179
description: Lookup all orders for the given user
180180
predicates:
@@ -189,7 +189,7 @@ spring:
189189
# ####################################################
190190
# acme-payment
191191
# ####################################################
192-
- uri: http://host.docker.internal:8084
192+
- uri: "http://${GATEWAY_HOST:host.docker.internal}:8084"
193193
description: /pay endpoint
194194
predicates:
195195
- Path=/pay
@@ -204,7 +204,7 @@ spring:
204204
# acme-shopping (frontend)
205205
# ####################################################
206206
- order: 999
207-
uri: http://host.docker.internal:8080
207+
uri: "http://${GATEWAY_HOST:host.docker.internal}:8080"
208208
predicates:
209209
- Path=/**
210210
- Method=GET

0 commit comments

Comments
 (0)