How to deploy to dedicated server using circleci - node.js

I am very new to CircleCi and trying to deploy a node/npm/vue app to plesk on contabo where domain is on a dedicated IP. The error has the following details.
ls -al rsync -a dist/* $SSH_USER#$SSH_HOSTNAME:/var/www/vhosts/mydomain.com/domain.com total 524
drwxrwxr-x 7 circleci circleci 4096 Sep 16 12:50 .
drwxr-xr-x 16 circleci circleci 4096 Sep 16 12:50 ..
-rw-rw-r-- 1 circleci circleci 66 Sep 16 12:50 babel.config.js
drwxrwxr-x 2 circleci circleci 4096 Sep 16 12:50 .circleci
drwxr-xr-x 6 circleci circleci 4096 Sep 16 12:49 dist
drwxrwxr-x 8 circleci circleci 4096 Sep 16 12:50 .git
-rw-rw-r-- 1 circleci circleci 230 Sep 16 12:50 .gitignore
-rw-rw-r-- 1 circleci circleci 107 Sep 16 12:50 jsconfig.json
-rw-rw-r-- 1 circleci circleci 1533 Sep 16 12:50 package.json
-rw-rw-r-- 1 circleci circleci 481935 Sep 16 12:50 package-lock.json
drwxrwxr-x 2 circleci circleci 4096 Sep 16 12:50 public
-rw-rw-r-- 1 circleci circleci 329 Sep 16 12:50 README.md
drwxrwxr-x 8 circleci circleci 4096 Sep 16 12:50 src
-rw-rw-r-- 1 circleci circleci 59 Sep 16 12:50 vue.config.js
ssh: connect to host ************* port 22: Connection timed out rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]
Exited with code exit status 255 CircleCI received exit code 255
Why am I getting this error and how do I resolve it?

Related

GitHub Actions: Error when copying generated directory to Docker image

I am using GitHub Actions to build our NestJS application.
These are some of the steps in the GitHub Actions workflow:
- name: Build Nest application
run: npm run build
- run: ls -al
- name: Build the Docker image
run: docker build . --file github.Dockerfile
github.Dockerfile looks like this:
FROM node:14-alpine as app
WORKDIR /usr/home/app
COPY package.json ./
COPY src ./
COPY node_modules ./
The build fails with this error message:
Step 5/5 : COPY node_modules ./
COPY failed: stat /var/lib/docker/tmp/docker-builder535687818/node_modules: no such file or directory
When listing the directory contents with RUN ls -al, this is the result:
drwxr-xr-x 9 runner docker 4096 Sep 29 12:53 .
drwxr-xr-x 3 runner docker 4096 Sep 29 12:52 ..
-rw-r--r-- 1 runner docker 1541 Sep 29 12:52 .dockerignore
-rw-r--r-- 1 runner docker 663 Sep 29 12:52 .eslintrc.js
-rw-r--r-- 1 runner docker 1300 Sep 29 12:52 .gcloudignore
drwxr-xr-x 8 runner docker 4096 Sep 29 12:52 .git
drwxr-xr-x 3 runner docker 4096 Sep 29 12:52 .github
-rw-r--r-- 1 runner docker 388 Sep 29 12:52 .gitignore
-rw-r--r-- 1 runner docker 51 Sep 29 12:52 .prettierrc
-rw-r--r-- 1 runner docker 3370 Sep 29 12:52 README.md
-rw-r--r-- 1 runner docker 162 Sep 29 12:52 cloudbuild.yaml
drwxr-xr-x 2 runner docker 4096 Sep 29 12:53 dist
-rw-r--r-- 1 runner docker 102 Sep 29 12:52 github.Dockerfile
drwxr-xr-x 2 runner docker 4096 Sep 29 12:52 k8s
-rw-r--r-- 1 runner docker 64 Sep 29 12:52 nest-cli.json
drwxr-xr-x 134 runner docker 4096 Sep 29 12:53 node_modules
-rw-r--r-- 1 runner docker 521420 Sep 29 12:52 package-lock.json
-rw-r--r-- 1 runner docker 1923 Sep 29 12:52 package.json
-rw-r--r-- 1 runner docker 471 Sep 29 12:52 skaffold.Dockerfile
-rw-r--r-- 1 runner docker 446 Sep 29 12:52 skaffold.yaml
drwxr-xr-x 2 runner docker 4096 Sep 29 12:52 src
drwxr-xr-x 2 runner docker 4096 Sep 29 12:52 test
-rw-r--r-- 1 runner docker 97 Sep 29 12:52 tsconfig.build.json
-rw-r--r-- 1 runner docker 339 Sep 29 12:52 tsconfig.json
package.json and src are part of the Git repository. node_modules gets generated in the process of the GitHub Action.
Why can't node_modules be copied to the Docker container, while both package.json and src can?
It turned out node_modules was included in the .dockerignore file. 🤦🏻‍♂️

AWS CodePipeline missing directories/files after being deployed to Elastic Beanstalk

This is a more-narrowed-down problem stemming from my earlier question.
Here is my buildspec.yml:
version: 0.2
phases:
install:
commands:
# upgrade AWS CLI
- pip install --upgrade awscli
# install Node 12
- curl -sL https://deb.nodesource.com/setup_12.x | bash -
- apt install nodejs
pre_build:
commands:
# install server dependencies
- npm install
build:
commands:
# install client dependencies and build static files
- npm install --prefix client && npm run build --prefix client
post_build:
commands:
# FOR TESTING AND DEBUGGING
- ls -la
- ls client -la
- mkdir client/TEST
- ls client -la
artifacts:
files:
- '**/*'
discard-paths: no
base-directory: '*'
In the post-build phase, I output directories for debugging and this is what they show:
[Container] 2020/07/02 02:36:15 Entering phase POST_BUILD
[Container] 2020/07/02 02:36:15 Running command ls -la
total 132
drwxr-xr-x 11 root root 4096 Jul 2 02:34 .
drwxr-xr-x 3 root root 4096 Jul 2 02:34 ..
-rw-rw-r-- 1 root root 129 Jul 2 02:33 .gitignore
-rw-rw-r-- 1 root root 16 Jul 2 02:33 .npmrc
-rw-rw-r-- 1 root root 34 Jul 2 02:33 README.md
-rw-rw-r-- 1 root root 1737 Jul 2 02:33 app.js
drwxr-xr-x 2 root root 4096 Jul 2 02:34 bin
-rw-rw-r-- 1 root root 655 Jul 2 02:33 buildspec.yml
drwxr-xr-x 6 root root 4096 Jul 2 02:35 client
drwxr-xr-x 2 root root 4096 Jul 2 02:34 config
drwxr-xr-x 2 root root 4096 Jul 2 02:34 graphql
drwxr-xr-x 2 root root 4096 Jul 2 02:34 models
drwxr-xr-x 197 root root 4096 Jul 2 02:34 node_modules
-rw-rw-r-- 1 root root 63888 Jul 2 02:33 package-lock.json
-rw-rw-r-- 1 root root 814 Jul 2 02:33 package.json
drwxr-xr-x 2 root root 4096 Jul 2 02:34 routes
drwxr-xr-x 2 root root 4096 Jul 2 02:34 services
drwxr-xr-x 2 root root 4096 Jul 2 02:34 views
[Container] 2020/07/02 02:36:15 Running command ls client -la
total 748
drwxr-xr-x 6 root root 4096 Jul 2 02:35 .
drwxr-xr-x 11 root root 4096 Jul 2 02:34 ..
drwxr-xr-x 3 root root 4096 Jul 2 02:36 build
drwxr-xr-x 1081 root root 36864 Jul 2 02:35 node_modules
-rw-rw-r-- 1 root root 699332 Jul 2 02:33 package-lock.json
-rw-rw-r-- 1 root root 1212 Jul 2 02:33 package.json
drwxr-xr-x 2 root root 4096 Jul 2 02:34 public
drwxr-xr-x 8 root root 4096 Jul 2 02:34 src
[Container] 2020/07/02 02:36:15 Running command mkdir client/TEST
[Container] 2020/07/02 02:36:15 Running command ls client -la
total 752
drwxr-xr-x 7 root root 4096 Jul 2 02:36 .
drwxr-xr-x 11 root root 4096 Jul 2 02:34 ..
drwxr-xr-x 2 root root 4096 Jul 2 02:36 TEST
drwxr-xr-x 3 root root 4096 Jul 2 02:36 build
drwxr-xr-x 1081 root root 36864 Jul 2 02:35 node_modules
-rw-rw-r-- 1 root root 699332 Jul 2 02:33 package-lock.json
-rw-rw-r-- 1 root root 1212 Jul 2 02:33 package.json
drwxr-xr-x 2 root root 4096 Jul 2 02:34 public
drwxr-xr-x 8 root root 4096 Jul 2 02:34 src
[Container] 2020/07/02 02:36:15 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/07/02 02:36:15 Phase context status code: Message:
[Container] 2020/07/02 02:36:15 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
[Container] 2020/07/02 02:36:15 Phase context status code: Message:
Which shows that client/build, client/node_modules, and a test directory client/TEST were all created during the CodeBuild. However when I go to the Beanstalk environment I get the error:
ENOENT: no such file or directory, stat '/var/app/current/client/build/index.html'
When I ssh into Beanstalk and check the /var/app/current/ directory, the node_modules in the root directory was successfully built. However, the client/build, client/node_modules, and client/TEST are all missing:
$ cd /var/app/current
$ ls
app.js buildspec.yml config models package.json Procfile routes views
bin client graphql node_modules package-lock.json README.md services
$ cd client
$ ls
package.json package-lock.json public src
This indicates to me that something messed up in the Deploy stage of the CodePipeline, or maybe the artifacts section of the buildspec.yml. I have been stuck on this issue for so long and have no idea how to go about it.
Based on the comments.
To deploy to ElasticBeanstalk, CodePipepine is using Elastic Beanstalk provider in a Deploy action. As part of setting up this action, input artifacts need to be specified.
The issue was that the input artifacts were set to use Source action, rather then the CodeBuild action.
The solution was to adjust the setting of the the Deploy action to use the CodeBuild artifacts, instead of Source artifacts.

How to update homebrew in preparation for installing node/npm on macOS Mojave

I attempted to install node.js/npm onto a macbook running Mojave 10.14.5 so that I can do local development of a web app. From internet research my understanding is the first step is updating homebrew in preparation for installation but I got the error "Error: /usr/local must be writable!" when I ran:
brew update
I searched the internet and other people appeared to have the command below fix the problem, but for me that didn't work and I still got the error.
sudo chown -R $(whoami) $(brew --prefix)/*
Can anyone offer any advice as to what I can do so that I can update brew and install node.js/npm? Is the brew update required or should I just skip that step?
Below is the output from brew --prefix that may help...
MacBook-Pro:usr dannyboy$ ls -l $(brew --prefix)
total 215896
-rw-r--r-- 1 dannyboy admin 3161 May 23 2016 CODEOFCONDUCT.md
drwxr-xr-x 5 dannyboy admin 160 Nov 4 2018 Cellar
-rw-r--r-- 1 dannyboy admin 1241 Jan 13 2016 LICENSE.txt
drwxr-xr-x 11 dannyboy admin 352 Nov 4 2018 Library
-rw-r--r-- 1 dannyboy admin 3918 May 23 2016 README.md
drwxrwxr-x 33 dannyboy admin 1056 Nov 4 2018 bin
drwxr-xr-x 3 dannyboy admin 96 Nov 4 2018 etc
lrwxr-xr-x 1 dannyboy admin 27 May 22 2016 hadoop -> /usr/local/hadoop-2.7.2-src
drwxr-xr-x# 22 dannyboy staff 704 Nov 4 2018 hadoop-2.7.2-src
-rw-r--r--# 1 dannyboy staff 110520320 May 22 2016 hadoop-2.7.2-src.tar
drwxrwxr-x 30 dannyboy admin 960 Nov 4 2018 include
drwxrwxr-x 23 dannyboy admin 736 Nov 4 2018 lib
drwxr-xr-x 5 dannyboy wheel 160 Nov 4 2018 man
lrwxr-xr-x 1 dannyboy wheel 27 Jan 18 2014 mysql -> mysql-5.6.15-osx10.7-x86_64
drwxr-xr-x 18 dannyboy wheel 576 Nov 4 2018 mysql-5.6.15-osx10.7-x86_64
-rw-r--r-- 1 dannyboy owner 1536 Jan 18 2014 mysql_db_backup_20140118.libertyrocks.tar
drwxr-xr-x 5 dannyboy admin 160 Nov 4 2018 opt
drwxr-xr-x 3 dannyboy wheel 96 Nov 4 2018 remotedesktop
drwxrwxr-x 9 dannyboy admin 288 Nov 4 2018 share
Also requested...
MacBook-Pro:usr dannyboy$ ls -l /usr
total 0
drwxr-xr-x 971 root wheel 31072 May 15 01:37 bin
drwxr-xr-x 307 root wheel 9824 May 15 01:37 lib
drwxr-xr-x 250 root wheel 8000 May 15 01:37 libexec
drwxr-xr-x 27 root wheel 864 Nov 4 2018 local
drwxr-xr-x 239 root wheel 7648 May 15 01:37 sbin
drwxr-xr-x 46 root wheel 1472 Nov 4 2018 share
drwxr-xr-x 5 root wheel 160 Sep 21 2018 standalone

kubernetes giving error,but code works

every time when deploying this images getting this error`
module.js:540
throw err;
^
Error: Cannot find module '/app/index.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
but code works on pc,I hadn't get error for other deployments they was done this way
dockerfile`
FROM node:8.9
ENV port 3000
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD ["sh", "-c", "node index.js --port=${port}"]
yaml `
output of RUN ls -la after COPY ./app
Step 7/8 : RUN ls -la
---> Running in 9e24667abd49
total 76
drwxr-xr-x 9 root root 4096 Jun 21 07:14 .
drwxr-xr-x 57 root root 4096 Jun 21 07:14 ..
-rw-rw-r-- 1 root root 30 May 31 09:00 .dockerignore
-rw-rw-r-- 1 root root 151 Jun 21 07:14 Dockerfile
-rw-rw-r-- 1 root root 556 Jun 20 15:16 api.yaml
drwxrwxr-x 2 root root 4096 May 23 09:03 controllers
-rw-rw-r-- 1 root root 446 Jun 20 15:18 index.js
drwxrwxr-x 3 root root 4096 May 15 11:27 insert
drwxrwxr-x 3 root root 4096 May 15 11:27 modules
drwxr-xr-x 69 root root 4096 Jun 20 15:07 node_modules
-rw-r--r-- 1 root root 20404 Jun 20 15:07 package-lock.json
-rw-rw-r-- 1 root root 328 May 31 09:02 package.json
drwxrwxr-x 2 root root 4096 May 15 11:27 services
drwxrwxr-x 2 root root 4096 Jun 14 14:56 settings
drwxrwxr-x 2 root root 4096 May 23 09:35 utilities
just forget this!!I've tagged the same container as new version,pushed and its works!
Answered by Grigor:
I've tagged the same container as new version,pushed and its works!

OpenJDK-9 JDK not present on Ubuntu 17.10

I'm trying to install java 9 jre and jdk on ubuntu. But i cannot find it. I installed all the packages:
ii openjdk-9-jdk:amd64 9~b181-4 amd64 OpenJDK Development Kit (JDK)
ii openjdk-9-jdk-headless:amd64 9~b181-4 amd64 OpenJDK Development Kit (JDK) (headless)
ii openjdk-9-jre:amd64 9~b181-4 amd64 OpenJDK Java runtime, using Hotspot JIT
ii openjdk-9-jre-headless:amd64 9~b181-4 amd64 OpenJDK Java runtime, using Hotspot JIT (headless)
Java -version returns:
openjdk version "9-Ubuntu"
OpenJDK Runtime Environment (build 9-Ubuntu+0-9b181-4)
OpenJDK 64-Bit Server VM (build 9-Ubuntu+0-9b181-4, mixed mode)
javac -version:
javac 9-Ubuntu
But when I try to create JDK in new Intellij:
Then i get error:
I checked the content of /usr/lib/jvm/ and:
For java-8-openjdk-amd64:
drwxr-xr-x 7 root root 4096 gru 17 16:16 ./
drwxr-xr-x 4 root root 4096 gru 18 18:11 ../
lrwxrwxrwx 1 root root 22 paź 24 00:43 ASSEMBLY_EXCEPTION -> jre/ASSEMBLY_EXCEPTION
drwxr-xr-x 2 root root 4096 gru 17 16:16 bin/
lrwxrwxrwx 1 root root 41 paź 24 00:43 docs -> ../../../share/doc/openjdk-8-jre-headless/
drwxr-xr-x 3 root root 4096 gru 17 16:16 include/
drwxr-xr-x 5 root root 4096 gru 17 16:16 jre/
drwxr-xr-x 3 root root 4096 gru 17 16:16 lib/
drwxr-xr-x 4 root root 4096 gru 17 16:16 man/
lrwxrwxrwx 1 root root 20 paź 24 00:43 src.zip -> ../openjdk-8/src.zip
lrwxrwxrwx 1 root root 22 paź 24 00:43 THIRD_PARTY_README -> jre/THIRD_PARTY_README
For java-9-openjdk-amd64:
drwxr-xr-x 9 root root 4096 gru 18 18:11 ./
drwxr-xr-x 4 root root 4096 gru 18 18:11 ../
drwxr-xr-x 2 root root 4096 gru 18 18:11 bin/
drwxr-xr-x 4 root root 4096 gru 18 18:11 conf/
lrwxrwxrwx 1 root root 41 sie 24 19:15 docs -> ../../../share/doc/openjdk-9-jre-headless/
drwxr-xr-x 3 root root 4096 gru 18 18:11 include/
drwxr-xr-x 2 root root 4096 gru 18 18:11 jmods/
drwxr-xr-x 77 root root 4096 gru 18 18:11 legal/
drwxr-xr-x 5 root root 4096 gru 18 18:11 lib/
drwxr-xr-x 4 root root 4096 gru 18 18:11 man/
lrwxrwxrwx 1 root root 20 sie 24 19:15 src.zip -> ../openjdk-9/src.zip
My question is what went wrong? To install java-9 i used:
sudo apt install openjdk-9-jre openjdk-9-jdk
I found an issue on idea tracker
https://youtrack.jetbrains.com/issue/IDEA-178743
It's fixed. Also users suggested x86_64- version. Try with it.(source)

Resources