简体   繁体   中英

How to build a react/vue application outside of a docker container

I have several applications (vue & react each of the applications is built on a different version of the node). I want to set up a project deployment so that I can run a docker container with the correct version of the node for each of the projects. A build ( npm i & npm run build ) should happen in the container, but I go to give the result from the container to /var/www/project_name already on the server itself.

Next, set up a container with nginx which, depending on the subdomain, will give the desired build

My question is how to return the folder with files from the container to the operating system area?

my docker-compose file:

version: "3.1"
services:
redis:
  restart: always
  image: redis:alpine
  container_name: redis

build-adminapp:
  build: adminapp/
  container_name: adminapp
  working_dir: /var/www/adminapp
  volumes:
    - ./adminapp:/var/www/adminapp

build-clientapp:
  build: clientapp/
  container_name: clientapp
  working_dir: /var/www/clientapp
  volumes:
    - ./clientapp:/var/www/clientapp`

my docker files:

FROM node:10-alpine as build
# Create app directory

WORKDIR /var/www/adminapp/
COPY . /var/www/adminapp/

RUN npm install
RUN npm run build

second docker file:

FROM node:12-alpine as build
# Create app directory

WORKDIR /var/www/clientapp/
COPY . /var/www/clientapp/

RUN npm install
RUN npm run build

If you already have a running container, you can use docker cp command to move files between local machine and docker containers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM