How to run app on sub-route in production docker container?

23 views Asked by At

We're running a vite app in a docker environment as our main app:

/docker/vite/Dockerfile (local):

FROM node:16

EXPOSE 5173

WORKDIR /var/www/html

ADD docker/vite/cmd/startnode startnode

RUN install -m 0755 startnode /usr/local/bin

CMD startnode

starnode:

yarn vite

/docker/vite/Dockerfile-dev (prod):

FROM node:16

EXPOSE 8080

COPY . /var/www/html
RUN mv /var/www/html/.Build/node_modules /var/www/html/node_modules \
    && rm -rf /var/www/html/src/dict \
    && mv /var/www/html/.Coverage/coverage /var/www/html/coverage \
    && mv /var/www/html/.Build/dict /var/www/html/src \
    && cp /var/www/html/.env.dev /var/www/html/.env \
    && cp /var/www/html/.Build/version.json /var/www/html/src/version.json
WORKDIR /var/www/html

RUN yarn vue-tsc && vite build

CMD ["node_modules/serve/build/main.js", "-s", "-l", "8080", "dist/"]

My assignment is to add a vitepress app on the sub-route /docs of our main app. I've got it to work locally but I can't get it to work in production.

/docker/vitepress/Dockerfile (local):

FROM node:16

EXPOSE 9000

WORKDIR /var/www/html

ADD docker/vitepress/cmd/startnode startnode

RUN install -m 0755 startnode /usr/local/bin

CMD startnode

startnode:

yarn run vitepress build docs --port=9000 --base=/docs/ --host

/docker/vitepress/Dockerfile-dev (prod):

FROM node:16

EXPOSE 9000

COPY . /var/www/html
RUN mv /var/www/html/.Build/node_modules /var/www/html/node_modules \
    && rm -rf /var/www/html/src/dict \
    && mv /var/www/html/.Coverage/coverage /var/www/html/coverage \
    && mv /var/www/html/.Build/dict /var/www/html/src \
    && cp /var/www/html/.env.dev /var/www/html/.env \
    && cp /var/www/html/.Build/version.json /var/www/html/src/version.json
WORKDIR /var/www/html

RUN yarn run vitepress build docs --port=9000 --base=/docs/ --host

CMD ["node_modules/serve/build/main.js", "-s", "-l", "9000", "dist/docs/"]

my vitepress config.ts has:

export default defineConfig({
  base: '/docs/',
})

I've tried running yarn vitepress build docs or yarn vitepress build docs --base=/docs/ instead without success. The vitepress app should be available on https://[domain]/docs

0

There are 0 answers