W: Webpacker requires Node.js ">=10.17.0" and you are using v6.17.1 - node.js

I try to deploy the rails 6 App on platform.sh,
I have this error when deploying my project in Rails 6 with Webpacker 5.2.1.
I have done days of research on google, without success.
I have NVM installed locally, node and npm, I will say that everything is fine locally, the webpacker is compiled correctly, but not on the remote machine.
and this error makes the deployment fail.
W: Webpacker requires Node.js ">=10.17.0" and you are using v6.17.1
W: Please upgrade Node.js https://nodejs.org/en/download/
W: Exiting!
E: Error building project: Step failed with status code 1.
E: Error: Unable to build application, aborting.
when I want to compile the assets with this line on Build hook.
RAILS_ENV=production bundle exec rails webpacker:install
can you help me
I'll share my config
.platform.app.yaml
# The name of this app. Must be unique within a project.
name: app
type: 'ruby:2.7'
mounts:
log:
source: local
source_path: log
tmp:
source: local
source_path: tmp
relationships:
postgresdatabase: 'dbpostgres:postgresql'
# The size of the persistent disk of the application (in MB).
disk: 1024
hooks:
build: |
bundle install --without development test
RAILS_ENV=production bundle exec rails webpacker:install
deploy: |
RAILS_ENV=production bundle exec rake db:migrate
web:
upstream:
socket_family: "unix"
commands:
start: "unicorn -l $SOCKET -E production config.ru"
locations:
'/':
root: "public"
passthru: true
expires: 1h
allow: true
services.yaml
dbpostgres:
# The type of your service (postgresql), which uses the format
# 'type:version'. Be sure to consult the PostgreSQL documentation
# (https://docs.platform.sh/configuration/services/postgresql.html#supported-versions)
# when choosing a version. If you specify a version number which is not available,
# the CLI will return an error.
type: postgresql:13
# The disk attribute is the size of the persistent disk (in MB) allocated to the service.
disk: 9216
configuration:
extensions:
- plpgsql
- pgcrypto
- uuid-ossp
routes.yaml
# Each route describes how an incoming URL is going to be processed by Platform.sh.
"https://www.{default}/":
type: upstream
upstream: "app:http"
"https://{default}/":
type: redirect
to: "https://www.{default}/"

Related

AWS CodeDeploy not running hooks scripts

I'm learning how to use CodePipeline and have problem with CodeDeploy for small testing node app. My target is to implement CD for large express + react app and I need to use hooks from AppSpec.yml.
For now everything else is working, files are copied etc, it just doesn't fire script. I started with BeforeInstall (delete process from pm2) and ApplicationStart (start app with pm2) hooks, but now I switched to using ApplicationStart with script to remove process from pm2 just to see if it works.
My AppSpec.yml:
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/api
permissions:
- object: /home/ubuntu/api/
owner: ubuntu
group: ubuntu
mode: "777"
# I use appStop.sh just to check if this works:
ApplicationStart:
- location: scripts/appStop.sh
runas: ubuntu
# I tried also running as root, still nothing
timeout: 60
appStop.sh:
#!/bin/bash
cd /home/ubuntu/api
pm2 delete 0
I tried many things, also running everything as root (though I prefer to use ubuntu user).
There are no ERRORs in log file in /var/log/aws/codedeploy-agent.
I can also see all files and scripts dir in reviev in /opt/codedeploy-agent/deployment-root/...
When I manually run appStop script in home dir it works.
It looks like CodeDeploy agent is just not running script.
Ok it seems I made it work.
First I cleaned codedeploy-agent data by removing /opt/deployment-root/<deployment droup id> dir and /opt/deployment-root/deployment-instructions
I also changed location, don't know if this helped, but had to do it since I decided to go with root user to make things easier. App is now in /var/www/api.
I also reinstalled all js software (node, pm2, npm) using sudo
My working AppSpec.yml:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/api
permissions:
- object: /var/www/api/
mode: 775
type:
- file
- directory
hooks:
ApplicationStop:
- location: scripts/appStop.sh
runas: root
ApplicationStart:
- location: scripts/appStart.sh
runas: root
and working scripts:
appStop.sh:
#!/bin/bash
cd /var/www/api
sudo pm2 delete 0
appStart.sh:
#!/bin/bash
cd /var/www/api
sudo pm2 start server.js

Running Nuxt.js in Docker Container build by Paketo.io / Cloud Native Buildpacks

I want to Containerize my Nuxt.js application. I could write my own Dockerfile (as mentioned in the Nuxt.js Google Cloud Run docs for example), but as Cloud Native Buildpacks are here to free us from the need to write those over and over again I wanted to simply use Paketo.io to build a Container from my Nuxt.js app.
I ran
pack build microservice-ui-nuxt-js --path . --builder paketobuildpacks/builder:base
and a Container was created successfully. Here's the full log:
$ pack build microservice-ui-nuxt-js --path . --builder paketobuildpacks/builder:base
base: Pulling from paketobuildpacks/builder
Digest: sha256:3e2ee17348bd901e7e0748e0e1ddccdf8a602b624e418927145b5f84ca26f264
Status: Image is up to date for paketobuildpacks/builder:base
base-cnb: Pulling from paketobuildpacks/run
Digest: sha256:b6b1612ab2dfa294514fff2750e8d724287f81e89d5e91209dbdd562ed7f7daf
Status: Image is up to date for paketobuildpacks/run:base-cnb
===> DETECTING
4 of 7 buildpacks participating
paketo-buildpacks/ca-certificates 2.2.0
paketo-buildpacks/node-engine 0.4.0
paketo-buildpacks/npm-install 0.3.0
paketo-buildpacks/npm-start 0.2.0
===> ANALYZING
Previous image with name "microservice-ui-nuxt-js" not found
===> RESTORING
===> BUILDING
Paketo CA Certificates Buildpack 2.2.0
https://github.com/paketo-buildpacks/ca-certificates
Launch Helper: Contributing to layer
Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
Paketo Node Engine Buildpack 0.4.0
Resolving Node Engine version
Candidate version sources (in priority order):
-> ""
<unknown> -> ""
Selected Node Engine version (using ): 14.17.0
Executing build process
Installing Node Engine 14.17.0
Completed in 5.795s
Configuring build environment
NODE_ENV -> "production"
NODE_HOME -> "/layers/paketo-buildpacks_node-engine/node"
NODE_VERBOSE -> "false"
Configuring launch environment
NODE_ENV -> "production"
NODE_HOME -> "/layers/paketo-buildpacks_node-engine/node"
NODE_VERBOSE -> "false"
Writing profile.d/0_memory_available.sh
Calculates available memory based on container limits at launch time.
Made available in the MEMORY_AVAILABLE environment variable.
Paketo NPM Install Buildpack 0.3.0
Resolving installation process
Process inputs:
node_modules -> "Not found"
npm-cache -> "Not found"
package-lock.json -> "Found"
Selected NPM build process: 'npm ci'
Executing build process
Running 'npm ci --unsafe-perm --cache /layers/paketo-buildpacks_npm-install/npm-cache'
Completed in 14.988s
Configuring launch environment
NPM_CONFIG_LOGLEVEL -> "error"
Configuring environment shared by build and launch
PATH -> "$PATH:/layers/paketo-buildpacks_npm-install/modules/node_modules/.bin"
Paketo NPM Start Buildpack 0.2.0
Assigning launch processes
web: nuxt start
===> EXPORTING
Adding layer 'paketo-buildpacks/ca-certificates:helper'
Adding layer 'paketo-buildpacks/node-engine:node'
Adding layer 'paketo-buildpacks/npm-install:modules'
Adding layer 'paketo-buildpacks/npm-install:npm-cache'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
Saving microservice-ui-nuxt-js...
*** Images (5eb36ba20094):
microservice-ui-nuxt-js
Adding cache layer 'paketo-buildpacks/node-engine:node'
Adding cache layer 'paketo-buildpacks/npm-install:modules'
Adding cache layer 'paketo-buildpacks/npm-install:npm-cache'
Successfully built image microservice-ui-nuxt-js
Now running
docker run --rm -i --tty -p 3000:3000 microservice-ui-nuxt-js
i hoped to see my app inside the Browser at http://localhost:3000. But no luck! My app doesn't seem to be fully running:
Although my console looks good:
What am I missing?
I read about the HOST variable in this post , which the whole problem is about! And then I also found this answer, since I now knew what to look for. The Nuxt.js configuration docs state it also:
By default, the Nuxt.js development server host is localhost which is
only accessible from within the host machine. In order to view your
app on another device you need to modify the host.
And the crucial config is mentioned also:
Host '0.0.0.0' is designated to tell Nuxt.js to resolve a host
address, which is accessible to connections outside of the host
machine (e.g. LAN)
So all we have to do is to define a Docker environment variable --env "HOST=0.0.0.0" and run the Paketo build Container like this:
docker run --rm -i --tty --env "HOST=0.0.0.0" -p 3000:3000 microservice-ui-nuxt-js
Now the Browser should also show our app at http://localhost:3000:
You can try it yourself using the GitHub Container Registry published image of the example project:
docker run --rm -i --tty --env "HOST=0.0.0.0" -p 3000:3000 ghcr.io/jonashackt/microservice-ui-nuxt-js:latest

npm start fails to run with AWS Code Deploy on AWS Windows instances

​I am trying to deploy a Node.js application on windows EC2 instances. Deployment finishes successfully but node server is not started automatically on those instances. I've to login to each instance to run command node app.js to start node server. I tried to include this command in appspec.yml file but then I got below error,
LifecycleEvent - ApplicationStart
Script - node_start.bat
[stdout]
[stdout]C:\Windows\system32>cd C:/host/
[stdout]
[stdout]C:\host>npm start
[stderr]'npm' is not recognized as an internal or external command,
[stderr]operable program or batch file.
​
My appspec.yml file is as below,
version: 0.0
os: windows
files:
- source: app.js
destination: c:\host
- source: package.json
destination: c:\host
- source: \node_modules
destination: c:\host\node_modules
- source: node_start.bat
destination: c:\host
- source: before_install.bat
destination: c:\host
hooks:
AfterInstall:
- location: before_install.bat
timeout: 300
ApplicationStart:
- location: node_start.bat
timeout: 300
Node is already installed on those two instances and Path variable is also properly set. Logging manually to those servers and running command npm start works perfectly fine. It fails only though AWS Code deploy.
I want to introduce AWS Lambda function also after this step to do health check.
Any help to resolve this issue would be greatly appreciated.
The issue isn't really related to CodeDeploy. CodeDeploy simply runs the script that you give it; in your case, node_start.bat. Perhaps, this question answers the issue that you're really having. CodeDeploy has no knowledge of your application unless you tell it.
You will likely either need to edit node_start.bat or your environment so that npm is a valid command.
Here are a couple of suggestions to help your case:
Test your appspec and scripts
You can test your appspec.yml and related scripts using the CodeDeploy local CLI, which comes with the agent.
Validate that your service is running
Obviously, it's not awesome if your deployment succeeds, but your application is not actually running. However, you can use the ValidateService lifecycle hook to confirm that your application is actually running or any other validation. You can include a script that can see that the process is running, confirm that no errors are getting logged, run tests, or whatever else you might want.

where are the build logs created when gcloud app deploy fails

Quick: where can I find the deployment logs for a node deploy which fails?
Setup: windows 10 box developing a node.js website. the website runs locally, and has deployed successfully with the same package stack (body-parser, express, firebase, firebase-tools, path, pug)
Google Cloud SDK 134.0.0
app-engine-python 1.9.40
bq 2.0.24
bq-win 2.0.24
core 2016.11.07
core-win 2016.11.07
gcloud
gsutil 4.22
gsutil-win 4.20
windows-ssh-tools 2016.05.13
The last few lines of the deploy output shows a core dump and timeout ends the deploy and how the latest gcloud update gacked up the logging output.
[91mnpm[0m[91m WARN using --force I sure hope you know what you are doing.
[0m
> group-coms#0.0.1 install /app
> npm install --force
[91mAborted (core dumped)
ERROR: (gcloud.app.deploy) Error Response: [4] DEADLINE_EXCEEDED
Oh yes, when it failed earlier today, I moved the folder to the root of the drive testing the 'too long a path' theory and it deployed successfully a couple of times. I haven't added or renamed any files since then, I have tried reloading all the node_modules to no avail.
# [START app_yaml]
runtime: nodejs
vm: true
# [END app_yaml]
I changed the yamal file to comply with upgrading#appyaml_changes and the deploy completed successfuly... I would still like to know more about how I can monitor the build process..

symfony2.3 configure assetic with less

I am using Symfony "2.3.*" and I attempt to make assetic less filter working.
I do all of this in the "dev" environment.
When I issue the config:dump-reference assetic I get the following output:
assetic:
debug: %kernel.debug%
use_controller:
enabled: %kernel.debug%
profiler: false
read_from: %kernel.root_dir%/../web
write_to: %assetic.read_from%
java: /usr/bin/java
node: /usr/bin/node
node_paths: []
ruby: /usr/bin/ruby
sass: /usr/bin/sass
variables:
# Prototype
name: []
bundles:
# Defaults:
- FrameworkBundle
- SecurityBundle
- TwigBundle
- MonologBundle
- SwiftmailerBundle
- AsseticBundle
- DoctrineBundle
- SensioFrameworkExtraBundle
- FOSUserBundle
- JMSSerializerBundle
- YuccaPrerenderBundle
- WebProfilerBundle
- SensioDistributionBundle
- SensioGeneratorBundle
assets:
# Prototype
name:
inputs: []
filters: []
options:
# Prototype
name: []
filters:
# Prototype
name: []
twig:
functions:
# Prototype
name: []
So, my config looks like :
assetic:
debug: %kernel.debug%
use_controller: false
bundles:
- PlastoriaGiftoFrontBundle
#java: /usr/bin/java
node: "/usr/bin/nodejs"
node_paths: [ "/home/webadmin/websites/gifto/node_modules" ]
filters:
cssrewrite: ~
less: ~
closure:
jar: %kernel.root_dir%/Resources/java/compiler.jar
yui_css:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar
To test that it works, I do open the Symfony Console and issue cache:clear
Then I go to the cache dir (app/cache) and do rm -rf *.
After I come back in Symfony console and launch these two commands:
assets:install
assetic:dump
And I am greeted with the following message :
Dumping all dev assets. Debug mode is on. 13:51:22 [file+]
/home/webadmin/websites/gifto/app/../web/css/ac28136.css
[Assetic\Exception\FilterException] An error occurred while running:
'/usr/bin/nodejs' '/tmp/assetic_lessjHtxDR' Error Output:
module.js:340
throw err;
^ Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:338:15) ... (truncated)
The configuration for the node binary is taken into account : An error occurred while running: '/usr/bin/nodejs'
By default, the value is /usr/bin/nodejs.
I can't figure out what's wrong. Did install "less" node module in the application using npm and when issuing npm ls, I can see it is properly installed.
I also launched nodejs in the application directory and did a require('less') and it worked without error.
What is the right way of configuring assetic with nodejs ?
For mac users this is
node: "/usr/local/bin/node"
node_paths: [/usr/local/lib/node_modules/]
Add
assetic:
node_paths: [/usr/lib/node_modules/]
in your config.yml file.
/usr/lib/node_modules/ works for Ubuntu.
I was using Centos with a cPanel installation. I made the mistake of not realizing when you run npm install less that it would be in the directory I called that from, which in my case was my project root directory.
Whatever directory you were in when you installed less the node_modules folder should be there. This is the wrong location for it however.
Assuming you are in the same directory you ran the install from... Run this command to move it to the correct location
mv node_modules /usr/local/lib/node_modules
Then you need to add a line to your config.yml
assetic:
debug: '%kernel.debug%'
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~
uglifyjs2:
# the path to the uglifyjs executable
bin: /usr/bin/uglifyjs
uglifycss:
bin: /usr/bin/uglifycss
less:
node_paths: [/usr/local/lib/node_modules/]
bin: /usr/bin/less
In my case I'm using a lot of other filters, but the key here is the node_paths: [/usr/local/lib/node_modules/], make sure you have that. Notice that is now set to a location that the script can access globally.
Now it will work. Hope this helps someone.
Found,
I entered in the server as root (Yes, I know, bad practice) then I su webadmin!
The trick is to really login as webadmin or su webadmin -l.
I tested and it was the issue.

Resources