Skip to content

Commit c58f939

Browse files
authored
fix: loading example assets without relying on redirects (#3247)
update docker debugging docs
1 parent 3ec731d commit c58f939

File tree

8 files changed

+36
-16
lines changed

8 files changed

+36
-16
lines changed

.vuestorefrontcloud/docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
You can debug dockerized docs image by following steps below:
66

7-
- build image using `DOCKER_BUILDKIT=1 docker build -t docs --build-arg VITE_DOCS_EXAMPLES_VUE_PATH=http://localhost:3001 --build-arg VITE_DOCS_EXAMPLES_REACT_PATH=http://localhost:3002 --build-arg VITE_DOCS_BASEPATH=/v2/ -f .vuestorefrontcloud/docs/Dockerfile .`,
8-
- run image using `docker run -t -i -p 3000:80 docs`, (flags `i` and `t` allows to run command and then kill it with `ctrl+c` https://github.com/moby/moby/issues/2838#issuecomment-29205965)
7+
- build image using `DOCKER_BUILDKIT=1 docker build -t docs --build-arg VITE_DOCS_EXAMPLES_VUE_PATH=http://localhost:3001/v2-vue --build-arg VITE_DOCS_EXAMPLES_REACT_PATH=http://localhost:3002/v2-react --build-arg VITE_DOCS_BASEPATH=/v2/ -f .vuestorefrontcloud/docs/Dockerfile .`,
8+
- run image using `docker run -t -i -p 3004:80 docs`, (flags `i` and `t` allows to run command and then kill it with `ctrl+c` https://github.com/moby/moby/issues/2838#issuecomment-29205965)
99
- open browser and go to the address `http://localhost:3000/v2/` to see the docs page running.
1010

11-
NOTE: docs will work but without `vue` and `react` showcases. For full docs experience you have to run `test-next` and `test-nuxt` docker as well.
11+
NOTE: docs will work but without `vue` and `react` showcases. For full docs experience you have to run `test-next` and `test-nuxt` docker as well. And to test root redirect to `/v2/` you need to run `router` docker image too.

.vuestorefrontcloud/router/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ An alternative to robots.txt in this case could be using the built-in Farmer fea
2727
However, I went with creating the "nginx + robots.txt file" container here anyways. I'm forced to create a container for nginx so might as well put the robots.txt file here.
2828

2929
That's a lot of work to do such a simple thing, but the situation is what it is.
30+
31+
## Debugging
32+
33+
You can debug dockerized docs image by following steps below:
34+
35+
- run `docs` docker image,
36+
- run terminal in `root` directory,
37+
- build image using `DOCKER_BUILDKIT=1 docker build -t docs-router --build-arg TARGET_DOMAIN=http://localhost:3004 -f .vuestorefrontcloud/router/docker/Dockerfile .`,
38+
- run image using `docker run -t -i -p 3000:3000 docs-router nginx-debug -g 'daemon off;'`, (flags `i` and `t` allows to run command and then kill it with `ctrl+c` https://github.com/moby/moby/issues/2838#issuecomment-29205965)
39+
- open browser and go to the address `http://localhost:3004` to see the app page running.

.vuestorefrontcloud/test-next/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ ARG VITE_DOCS_BASEPATH
88
ARG VITE_DOCS_EXAMPLES_REACT_PATH
99
ARG ENVIRONMENT
1010

11-
ENV VITE_DOCS_BASEPATH=$VITE_DOCS_BASEPATH
12-
ENV VITE_DOCS_EXAMPLES_REACT_PATH=$VITE_DOCS_EXAMPLES_REACT_PATH
11+
ENV NEXT_DOCS_BASEPATH=$VITE_DOCS_BASEPATH
12+
ENV NEXT_DOCS_EXAMPLES_REACT_PATH=$VITE_DOCS_EXAMPLES_REACT_PATH
1313
ENV ENVIRONMENT=$ENVIRONMENT
1414

1515
RUN yarn

.vuestorefrontcloud/test-next/docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
You can debug dockerized docs image by following steps below:
66

77
- run terminal in `root` directory
8-
- build image using `DOCKER_BUILDKIT=1 docker build -t test-next -f .vuestorefrontcloud/test-next/docker/Dockerfile .`,
8+
- build image using `DOCKER_BUILDKIT=1 docker build -t test-next --build-arg VITE_DOCS_EXAMPLES_REACT_PATH=https://localhost:3002/v2-react -f .vuestorefrontcloud/test-next/docker/Dockerfile .`,
99
- run image using `docker run -t -i -p 3002:3000 test-next`, (flags `i` and `t` allows to run command and then kill it with `ctrl+c` https://github.com/moby/moby/issues/2838#issuecomment-29205965)
1010
- open browser and go to the address `http://localhost:3002` to see the app page running.

.vuestorefrontcloud/test-nuxt/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ ARG VITE_DOCS_BASEPATH
88
ARG VITE_DOCS_EXAMPLES_VUE_PATH
99
ARG ENVIRONMENT
1010

11-
ENV VITE_DOCS_BASEPATH=$VITE_DOCS_BASEPATH
12-
ENV VITE_DOCS_EXAMPLES_VUE_PATH=$VITE_DOCS_EXAMPLES_VUE_PATH
11+
ENV NUXT_DOCS_BASEPATH=$VITE_DOCS_BASEPATH
12+
ENV NUXT_DOCS_EXAMPLES_VUE_PATH=$VITE_DOCS_EXAMPLES_VUE_PATH
1313
ENV ENVIRONMENT=$ENVIRONMENT
1414

1515
RUN yarn

.vuestorefrontcloud/test-nuxt/docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
You can debug dockerized docs image by following steps below:
66

77
- run terminal in `root` directory
8-
- build image using `DOCKER_BUILDKIT=1 docker build -t test-nuxt -f .vuestorefrontcloud/test-nuxt/docker/Dockerfile .`,
8+
- build image using `DOCKER_BUILDKIT=1 docker build -t test-nuxt --build-arg VITE_DOCS_EXAMPLES_VUE_PATH=https://localhost:3002/v2-vue -f .vuestorefrontcloud/test-nuxt/docker/Dockerfile .`,
99
- run image using `docker run -t -i -p 3001:3000 test-nuxt`, (flags `i` and `t` allows to run command and then kill it with `ctrl+c` https://github.com/moby/moby/issues/2838#issuecomment-29205965)
1010
- open browser and go to the address `http://localhost:3001` to see the app page running.

apps/preview/next/next.config.mjs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const isProd = process.env.PROD === 'true';
66
/** @type {import('next').NextConfig} */
77
export default {
88
env: {
9-
DOCS_EXAMPLES_REACT_PATH: process.env.VITE_DOCS_EXAMPLES_REACT_PATH || '',
9+
DOCS_EXAMPLES_REACT_PATH: process.env.NEXT_DOCS_EXAMPLES_REACT_PATH || '',
1010
},
11-
basePath: process.env.VITE_DOCS_EXAMPLES_REACT_PATH
12-
? new URL(process.env.VITE_DOCS_EXAMPLES_REACT_PATH).pathname
11+
basePath: process.env.NEXT_DOCS_EXAMPLES_REACT_PATH
12+
? new URL(process.env.NEXT_DOCS_EXAMPLES_REACT_PATH).pathname
1313
: '',
1414
reactStrictMode: true,
1515
swcMinify: true,
@@ -49,14 +49,24 @@ export default {
4949
},
5050
});
5151

52-
const reactPackage = resolve(process.cwd(), '..', '..', '..', 'packages', 'sfui', 'frameworks', 'react', 'index.ts');
52+
const reactPackage = resolve(
53+
process.cwd(),
54+
'..',
55+
'..',
56+
'..',
57+
'packages',
58+
'sfui',
59+
'frameworks',
60+
'react',
61+
'index.ts',
62+
);
5363
config.resolve.alias = {
5464
...config.resolve.alias,
5565
'@storefront-ui/react': reactPackage,
5666
'@storefront-ui/vue': reactPackage,
57-
}
67+
};
5868
}
5969

6070
return config;
61-
}
71+
},
6272
};

apps/preview/nuxt/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const isProd = process.env.PROD === 'true';
66

77
export default defineNuxtConfig({
88
app: {
9-
baseURL: process.env.VITE_DOCS_EXAMPLES_VUE_PATH ? new URL(process.env.VITE_DOCS_EXAMPLES_VUE_PATH).pathname : '',
9+
baseURL: process.env.NUXT_DOCS_EXAMPLES_VUE_PATH ? new URL(process.env.NUXT_DOCS_EXAMPLES_VUE_PATH).pathname : '',
1010
head: {
1111
htmlAttrs: {
1212
lang: 'en',

0 commit comments

Comments
 (0)