Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nodejs) : Fixed nodejs deployer scripts #1161

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

rpaliwal1997
Copy link
Contributor

@rpaliwal1997 rpaliwal1997 commented Feb 12, 2025

Fixed the Node.js deployer scripts to support both Docker and Linux on-host installation flows.

Ansible playbook validation
Docker
image

NodeJs Docker Based Instrumentation:-

image

Ansible playbbok validation for OnHost
image

NodeJs OnHost Linux Based Instrumentation:-

image

More informations can be found in JIRA ticket

Comment on lines 7 to 18
# create a sample Dockerfile
- name: Create a sample Dockerfile
copy:
content: |
FROM node:18
WORKDIR /app
COPY . /app
RUN npm install
EXPOSE 3000
CMD ["node", "app.js"]
dest: "/home/{{ ansible_user }}/myNodeApp/Dockerfile"
mode: "0644"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good overall! For better readability, I was wondering if we could exclude the Dockerfile and sample application example changes from main.yml and move them under templates directory, similar to the existing structure for NodeJS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Nandu-pns the suggested changes are done!!

Comment on lines 53 to 71
- name: Create sample Node.js application
copy:
content: |
const http = require('http');

# - name: set node.js version 20.5.1 as default
# shell: nvm alias default 20.5.1
const hostname = '127.0.0.1';
const port = 3000;

# - name: Create node.js app directory
# file:
# path: /home/ec2-user/myNodeApp
# state: directory
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, Node.js!\n');
});

# - name: Copy files to myNodeApp directory
# synchronize:
# src: "{{ item }}"
# dest: /home/ec2-user/myNodeApp
# mode: push
# with_fileglob:
# - "../../../../templates/*"
# become: true
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
dest: "/home/{{ ansible_user }}/myNodeApp/app.js"
mode: "0644"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants