1

365体育足球滚球比分I'm trying to deploy multiple projects on same path.

I'm working with a virtualbox using ubuntu. I've created a folder called multiprojects and inside there are 3 folders with one project inside eachone: demo, project1 and project2.

  • demo folder contains all files builded after call npm run build on demo project.

  • project1 folder contains a folder, with name build, that contains all files buided after call npm run build on project1.

  • project2 folder contains a folder, with name build, that contains all files buided after call npm run build on project2.

Also, project1 contains "homepage" in package.json that redirect to project1. "homepage": "/project1". project2 contains "homepage" in package.json that redirect to project2. "homepage": "/project2" and demo project doesnt contains homepage in pacakage.json

Each projeact has in App.js is own public path:

365体育足球滚球比分For example, in demo project has as a publicPath /demo, in project1 /project1 and finally in project2 /project2

const publicPath = "/demo";

return (
    translations &&
    styles && (
        <BrowserRouter basename={publicPath}>
            <ToastProvider>
                <IntlProvider
                    key={settings.locale}
                    locale={settings.locale}
                    defaultLocale="en"
                    messages={translations[settings.locale]}
                >
                    <Routes />
                </IntlProvider>
            </ToastProvider>
        </BrowserRouter>
    )

365体育足球滚球比分And this is my nginx config:

server {
    listen  8090;
    server_name localhost;
    index index.html index.htm;

        location /project1 {
            root /home/osboxes/Documents/multiproject/project1/build;
            try_files $uri $uri/ /index.html;
        }

        location /project2 {
            root /home/osboxes/Documents/multiproject/project2/build;
            try_files $uri $uri/ /index.html;
        }

        location / {
            root /home/osboxes/Documents/multiproject/demo;
            try_files $uri $uri/ /index.html;
        }
    }

365体育足球滚球比分I have two questions:

  • How can I do it better?
  • How can do this in a docker file?
  • The way you're doing it now seems fine; I wouldn't even drag Docker into the picture since the output of npm build is just static files that a non-container Nginx can serve just fine. Is there a specific problem you're running into? – David Maze Mar 31 at 21:47
  • No, only that if there is a better way to do it. Now is running in virtualbox with ubuntu and works fine. – Javier Apr 1 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy365体育足球滚球比分

Browse other questions tagged or ask your own question.