Skip to content

Commit

Permalink
feat(nodejs): Add deploy config for nodejs (#1137)
Browse files Browse the repository at this point in the history
* feat(nodejs): Add node js and docker deploy config
  • Loading branch information
abasha1234 authored Dec 9, 2024
1 parent ce58007 commit cc4102a
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/deploy/linux/nodejs/redhat/roles/configure/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
- debug:
msg: Install Nodejs and docker

- name: update yum packages
shell: yum update -y
become: true

- name: install docker
shell: yum install docker
become: true

- name: RHEL - Start docker service
shell: "service docker start"

# - name: RHEL - Granting permissions to docker from ec2-user
# shell: "usermod -a -G docker ec2-user"

# - name: Install Node.js
# shell: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# become: true

# - name: load nvm
# shell: source ~/.bashrc

# - name: install node.js 20.5.1
# shell: nvm install 20.5.1

# - name: set node.js version 20.5.1 as default
# shell: nvm alias default 20.5.1

# - name: Create node.js app directory
# file:
# path: /home/ec2-user/myNodeApp
# state: directory

# - name: Copy files to myNodeApp directory
# synchronize:
# src: "{{ item }}"
# dest: /home/ec2-user/myNodeApp
# mode: push
# with_fileglob:
# - "../../../../templates/*"
# become: true

# - name: create package.json
# shell: cd /home/ec2-user/myNodeApp && npm init -y
# become: true

# - name: install express
# shell: cd /home/ec2-user/myNodeApp && npm install express
# become: true

19 changes: 19 additions & 0 deletions test/deploy/linux/nodejs/templates/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Dockerfile

FROM node

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY package*.json ./
RUN npm install

# Bundle app source
COPY . .

# Expose the port the app runs on
EXPOSE 3030

# Command to run the application
CMD [ "node", "index.js" ]
18 changes: 18 additions & 0 deletions test/deploy/linux/nodejs/templates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// index.js

// Load the New Relic agent before anything else
require('newrelic');

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3030;

// Simple route for testing
app.get('/', (req, res) => {
res.send('Hello World! This is my Node.js app instrumented with New Relic.');
});

// Start the server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
29 changes: 29 additions & 0 deletions test/manual/definitions/apm/node/node-js-docker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"global_tags": {
"owning_team": "virtuoso",
"Environment": "development",
"Department": "product",
"Product": "virtuoso"
},
"resources": [
{
"id": "node-js-docker",
"provider": "aws",
"type": "ec2",
"size": "t2.medium",
"ami_name": "amzn2-ami-hvm-2.0.????????.?-x86_64-gp2",
"user_name": "ec2-user"
}
],
"services": [
{
"id": "nodejs",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/nodejs/redhat/roles",
"port": 8080,
"destinations": [
"node-js-docker"
]
}
]
}

0 comments on commit cc4102a

Please sign in to comment.