Skip to content

Instantly share code, notes, and snippets.

@umidjons
Last active August 8, 2017 13:24
Show Gist options
  • Save umidjons/0945cb803e8443681c43b8cf8be93558 to your computer and use it in GitHub Desktop.
Save umidjons/0945cb803e8443681c43b8cf8be93558 to your computer and use it in GitHub Desktop.
Dockerfile-s to test node.js and npm packages discovery and automation

How to check NodeJS plugin

Build images:

docker build -t mynode .
docker build -f Dockerfile-centos -t mynode .

Run the container:

docker run -d --name my_node -p 22:22 mynode

Find out IP:

docker inspect --format "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" my_node

Update hosts file:

[ec2instances]
my_node ansible_ssh_host=172.17.0.2 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=root@123

Run automation script:

sudo ansible-playbook -i hosts ec2discovery.yml -v

Check results in aurea-docker-automation-linux/results/my_node_20170808_175854.18693/dockerized/dockerfiles/__ALL_TOOLS__/Dockerfile file.

That's it!

FROM ubuntu:16.04
ENV APT_OPTS="-o Acquire::http::Timeout=3 -o Acquire::Retries=100"
RUN apt-get update $APT_OPTS \
&& apt-get install $APT_OPTS -y curl openssh-server python \
&& echo "root:root@123" | chpasswd \
&& sed -ri -e 's|(^PermitRootLogin )(.*)|\1yes|g' /etc/ssh/sshd_config \
&& mkdir -p /var/run/sshd \
&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get install $APT_OPTS -y nodejs \
&& npm i -g color
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
FROM centos:6
RUN yum install -y gcc-c++ \
&& curl -sL https://rpm.nodesource.com/setup_6.x | bash - \
&& yum install -y nodejs \
&& yum install -y openssh-server \
&& echo "PermitRootLogin yes" >> /etc/ssh/sshd_config \
&& echo "Port 22" >> /etc/ssh/sshd_config \
&& echo "root:root@123" | chpasswd \
&& service sshd start && service sshd stop \
&& npm install -g color
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment