I'm pretty new to AWS Amplify and I'm trying to deploy an app with my own frontend and backend, I have successfully deployed the frontend but I can't figure out how to connect the backend (it seems like the server is not responding).
Here's my project structure:
And Here's my amplify.yml
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
# IMPORTANT - Please verify your build commands
build:
commands: []
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: 'client'
files:
- '**/*'
cache:
paths:
- node_modules/**/*
I got a warning on the website:
Failed to load resource: the server responded with a status of 404 ()
I also tried adding the code below to the yml
version: 1
env:
variables:
key: value
backend:
phases:
build:
commands:
- amplifyPush --simple
But the application failed when building
Not sure if this has something to do with using express.js in node.js
Related
I have a simple Ember.js single page web application that was created using this Ember.js tutorial (finished part 1 & 2):
Ember.js Tutorial
I am now trying to get familiar with Azure CI/CD pipelines by first creating an Azure DevOps Git Repo for the application, then a Build pipeline that is triggered by a push to the Git Repo, and finally a Release pipeline to publish the site to an Azure App Service after the build has succeeded.
The build and release pipelines both succeed, but when I visit the site, it shows a blank node.js page:
Can someone help me figure out where I went wrong here? My guess is it has to do with something in the configuration of the build and/or the release pipeline. Just can't seem to find what specific part is not correct. Any help is much appreciated. I can provide more information if needed :)
Here are my configurations for the build pipeline
YAML code for build pipeline
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool#0
inputs:
versionSpec: '6.x'
checkLatest: true
- task: Npm#1
inputs:
command: 'install'
workingDir: 'app/'
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
Here is the configuration in the Release Pipeline
Artifact Configuration
Continuous deployment configuration
Stage 1: Deployment Process
Agent Job
YAML for Deploying to Azure App Service
steps:
- task: AzureRmWebAppDeployment#4
displayName: 'Deploy Azure App Service'
inputs:
azureSubscription: '$(Parameters.ConnectedServiceName)'
appType: '$(Parameters.WebAppKind)'
WebAppName: '$(Parameters.WebAppName)'
RuntimeStack: 'NODE|14-lts'
StartupCommand: '$(Parameters.StartupCommand)'
WebConfigParameters: '-Handler iisnode -NodeStartFile server.js -appType node'
AppSettings: '-WEBSITE_NODE_DEFAULT_VERSION 6.9.1'
I would also like to mention that the Azure App Service stack setting is Node 14 and is running on linux.
Thanks!
I'm building an application which uses Node, redis and mongo. I finished the development, and I want to containerize it with docker.
Here's my Dockerfile:
FROM node:13.8.0-alpine3.11
RUN npm install -g pm2
WORKDIR /user/src/app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3000
And here my docker-compose.yml
version: '3'
services:
redis-server:
container_name: scrapr-redis
image: 'redis:6.0-rc1-alpine'
ports:
- '6379:6379'
mongo-db:
container_name: scrapr-mongo
image: mongo
ports:
- '27017:27017'
command: --auth
environment:
- MONGO_INITDB_ROOT_USERNAME=user
- MONGO_INITDB_ROOT_PASSWORD=pass
- MONGO_INITDB_DATABASE=db
app:
container_name: scrapr-node
restart: always
build: .
ports:
- '3000:3000'
- '3001:3001'
links:
- mongo-db
depends_on:
- redis-server
environment:
- DB_USER=user
- DB_PWD=pass
- DB_NAME=db
- REDIS_HOST=redis-server
command: 'node index.mjs'
I can start the service successfully, but when node starts, it generates the following error:
Error Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
When I do docker ps -a, I can see that all containers are running:
Why can't it connect with redis? What did I miss?
127.0.0.1 does not look right to me at all. Let me get the quick checks out of the way first, are you sure you are using the REDIS_HOST env variable in the node app correctly? I would add some console logging to your node app to echo out the env variables to check what they are.
Secondly try attach to the running scrapr-node with docker container exec -it scrapr-node sh or /bin/bash if sh does not work.
Then run nslookup scrapr-redis from the shell, this will give you the ip address of the redis container. if ping scraper-redis returns then you know its an issue with your node app not the docker network.
you can also exec into the redis node and run hostname -I which should show the same ip address as you saw from the other container.
This should help you to debug the issue.
EDIT:
Ensure that you are correctly getting the value from your environment into your node app using process.env.REDIS_HOST and then correctly using that value when connecting to redis something like:
const redisClient = redis.createClient({
host: process.env.REDIS_HOST,
port: 6379
});
I would not try and force 127.0.0.1 on the docker network (if that is even possible) it is reserved as the loopback address.
I am developing an app and I want to deploy it on a linux server. I already have copy my local files to the server . I have read this article but not so clear to me https://github.com/keystonejs/keystone/issues/4687.
things i have already done
Remote server has appropriate versions of Node.js & npm installed (ideally the same as what you have been testing with in development)
Check out (or copy) the latest version of your application source to the remote server.
Run npm install (or npm install --production if this will be a production environment) in the top-level of your application source directory.
but when i run npm start on the server it gives me error which is
Mongoose connection "error" event fired with:
{ MongoError: failed to connect to server [localhost:27017] on first connect
my settings
keystone.init({
'name': 'Test',
'brand': 'Test',
'sass': 'public',
'static': 'public',
'favicon': 'public/favicon.ico',
'auto update': true,
'views': 'templates/views',
'view engine': '.html',
'custom engine': cons.nunjucks,
'mongo': 'mongodb://localhost/test',
'auto update': true,
'emails': 'templates/email',
'session': true,
'auth': true,
'user model': 'User',
});
Do i need to configure more settings on mongo on the server?
Mongoose connection "error" event fired with: { MongoError: failed to connect to server [localhost:27017] on first connect
The above error means that your mongodb service was not started.
To enable & start the mongodb service you can run following command:
1. Enable mongodb service
sudo systemctl enable mongod.service
2. Start mongodb service
sudo service mongod start
3. Start your nodejs app
npm start
I've been having troubles with getting gitlab to send jobs to sonarqube. I have installed the sonarqube plugin and added my gitlab user token to the sonarqube server. In my gitlab-ci.yml I run the following command:
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
- cd /opt
- wget -q https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip
- unzip -qq sonar-scanner-cli-3.2.0.1227-linux.zip
- cd /builds/my_user_name/my_project/backend
- /opt/sonar-scanner-3.2.0.1227-linux/bin/sonar-scanner -X -Dsonar.host.url=http://34.230.xx.xx -Dsonar.projectKey=$CI_PROJECT_NAME.develop -Dsonar.projectVersion=$CI_COMMIT_SHA -Dsonar.gitlab.url=https://www.gitlab.com -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.user_token=$SONAR_PLUGIN_TOKEN -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.analysis.mode=preview -Dsonar.sources=.
The error I get is the following. I get this error both with using the npm sonarqube-scanner as well. Does anyone know what is going on?
05:12:15.795 DEBUG: * GitLab 3.0.0 (gitlab)
05:12:16.171 INFO: Process project properties
05:12:16.184 DEBUG: Process project properties (done) | time=13ms
05:12:16.199 INFO: Load project repositories
05:12:16.227 DEBUG: GET 404 http://34.230.xx.xx/batch/project.protobuf?key=my_key_here&issues_mode=true | time=25ms
05:12:16.229 DEBUG: Project repository not available - continuing without it
05:12:16.234 WARN: Project doesn't exist on the server. All issues will be marked as 'new'.
05:12:16.235 INFO: Load project repositories (done) | time=36ms
05:12:16.314 INFO: Scanning only changed files
05:12:16.317 INFO: Execute project builders
05:12:16.999 INFO: ------------------------------------------------------------------------
05:12:17.006 INFO: EXECUTION FAILURE
05:12:17.007 INFO: ------------------------------------------------------------------------
05:12:17.008 INFO: Total time: 4.682s
05:12:17.050 INFO: Final Memory: 11M/104M
05:12:17.051 INFO: ------------------------------------------------------------------------
05:12:17.052 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:265)
at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:120)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:133)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.DefaultInputModuleHierarchy
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
.....
Check your Sonar plugins versions, compared to your SonarQube version.
As in this thread, you would (for instance) be running SonarQube 7.1 with extensions made for SonarQube 7.0 (Branch, Developer).
The OP Coherent reports in the comments using:
docker run -d --name sonarqube -p 80:9000 -p 9092:9092 \
-e SONARQUBE_JDBC_USERNAME=x
-e SONARQUBE_JDBC_PASSWORD=y
-e SONARQUBE_JDBC_URL=jdbc:postgresql://mydatabase-east-1.rds.amazonaws.com/sonar sonarqube:7.0
Tibor Blenessy adds
Try to remove -Dsonar.analysis.mode=preview, this option is no longer supported.
I have a digital ocean droplet that I am trying to deploy the most basic of meteor apps to, but I am getting a failing response. Any idea why this is happening?
UPDATE: added entire output
Anderss-iMac:microscope-deploy anderskitson$ mup deploy
Meteor-UP : Production Quality Meteor Deployments
--------------------------------------------------
Bundling Started: /Users/anderskitson/sites/microscope
Started TaskList: Deploying App
[bray.anderskitson.ca] uploading bundle
[bray.anderskitson.ca] uploading bundle: SUCCESS
[bray.anderskitson.ca] setting up env vars
[bray.anderskitson.ca] setting up env vars: SUCCESS
[bray.anderskitson.ca] invoking deployment process
[bray.anderskitson.ca] invoking deployment process: FAILED
-----------------------------------STDERR-----------------------------------
Warning: Permanently added 'bray.anderskitson.ca,162.243.52.235' (RSA) to the list of known hosts.
npm WARN package.json http-proxy#1.0.0 No repository field.
npm http GET https://registry.npmjs.org/fibers
npm http 304 https://registry.npmjs.org/fibers
stop: Unknown instance:
bash: line 46: wait-for-mongo: command not found
-----------------------------------STDOUT-----------------------------------
> fibers#1.0.1 install /opt/meteor/tmp/bundle/programs/server/node_modules/fibers
> node ./build.js
`linux-x64-v8-3.14` exists; testing
Binary is fine; exiting
fibers#1.0.1 node_modules/fibers
meteor start/running, process 10373
wait for mongo(5 minutes) to initiaze
----------------------------------------------------------------------------
Completed TaskList: Deploying App
I ran into same problem and I figured out that this command wasn't fired really well
sudo npm install -g forever userdown wait-for-mongo
and I manually did that so I can see wait-for-mongo a valid command,
see if that helps you too.