> For the complete documentation index, see [llms.txt](https://andreis-organization-17.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andreis-organization-17.gitbook.io/devops/ci-cd/bitbuket-build-and-deploy-react-frontend-node-bakend-to-vm.md).

# Bitbuket Build and Deploy React Frontend, Node Bakend to Vm

Bitbuket Pipe

````yaml
```yaml
image: node:18

pipelines:
  branches:
    development:
      - step:
          name: "Сopy on VPS (DEV)"
          deployment: DEV
          script:
            - apt-get update -y && apt-get install gettext-base -y
            - pipe: atlassian/rsync-deploy:0.3.2
              variables:
                USER: $BACKEND_USER
                SERVER: $BACKEND_SERVER
                REMOTE_PATH: /home/root/dev
                LOCAL_PATH: "$BITBUCKET_CLONE_DIR"
                SSH_ARGS: "-o StrictHostKeyChecking=no"

      - step:
          name: "Build Backend"
          script:
            - pipe: atlassian/ssh-run:0.2.8
              variables:
                SSH_USER: $BACKEND_USER
                SERVER: $BACKEND_SERVER
                MODE: "command"
                COMMAND: "cd /home/root/dev/build/front && yarn && yarn build"
                SSH_ARGS: "-o StrictHostKeyChecking=no"

      - step:
          name: "Build Frontend"
          script:
            - pipe: atlassian/ssh-run:0.2.8
              variables:
                SSH_USER: $BACKEND_USER
                SERVER: $BACKEND_SERVER
                MODE: "command"
                COMMAND: "cd /home/root/dev/build/back && yarn && yarn build"
                SSH_ARGS: "-o StrictHostKeyChecking=no"

      - step:
          name: "Run Frontend and Bakend"
          script:
            - pipe: atlassian/ssh-run:0.2.8
              variables:
                SSH_USER: $BACKEND_USER
                SERVER: $BACKEND_SERVER
                MODE: "command"
                # COMMAND: "cd /home/root/build/back && yarn && yarn build && sudo pm2 update"
                COMMAND: "cd /home/root/dev/build && docker-compose -f docker-compose-dev.yaml up --build -d"
                SSH_ARGS: "-o StrictHostKeyChecking=no"

```
````

Dokerfile Frontend

```dockerfile
FROM nginx:latest

COPY ./dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
```

Dockerfile Bakend

```dockerfile
FROM node:18

WORKDIR /app

COPY . .

CMD ["node", "dist/main.js"]
```
