Setup Web Terminal using Wetty Docker Image

Chairat Onyaem
Mar 23, 2018 · 4 min read
Image for post
Image for post

Introduction

What is Wetty?

Prerequisite

Installation

$ git clone git@github.com:krishnasrinivas/wetty.git
$ vim Dockerfile
FROM node:0.10.38
MAINTAINER Nathan LeClaire <nathan@docker.com>
ADD . /app
WORKDIR /app
RUN npm install
RUN apt-get update
RUN apt-get install -y vim
RUN useradd -d /home/term -m -s /bin/bash term
RUN echo 'term:term' | chpasswd
EXPOSE 3000ENTRYPOINT ["node"]
CMD ["app.js", "-p", "3000"]
$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 30000 -nodes
Country Name (2 letter code) [AU]:TH
State or Province Name (full name) [Some-State]:Bangkok
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Demo Company
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:terminal.yourdomain.com
Email Address []:admin@yourdomain.com
CMD ["app.js", "--sslkey", "key.pem", "--sslcert", "cert.pem", "-p", "3000"]
RUN mkdir /home/term/.ssh
COPY id_rsa /home/term/.ssh/id_rsa
RUN chmod 600 /home/term/.ssh/id_rsa && chown -Rf term /home/term/.ssh
RUN echo 'term:yourpassword' | chpasswd
FROM node:0.10.38
MAINTAINER admin@yourdomain.com
ADD . /app
WORKDIR /app
RUN npm install
RUN apt-get update
RUN apt-get install -y vim
RUN useradd -d /home/term -m -s /bin/bash term
RUN echo 'term:yourpassword' | chpasswd
RUN mkdir /home/term/.ssh
COPY id_rsa /home/term/.ssh/id_rsa
RUN chmod 600 /home/term/.ssh/id_rsa && chown -Rf term /home/term/.ssh
EXPOSE 3000ENTRYPOINT ["node"]
CMD ["app.js", "--sslkey", "key.pem", "--sslcert", "cert.pem", "-p", "3000"]

Build Your Docker Image

$ sudo docker build -t yourusername/wetty .
$ sudo docker build -t demo/wetty .
Sending build context to Docker daemon 1.042MB
Step 1/15 : FROM node:0.10.38
---> 82073591bd0c
Step 2/15 : MAINTAINER admin@yourdomain.com
---> Using cache
---> 067a8d078ccb
Step 3/15 : ADD . /app
---> ccd418e158ee
Step 4/15 : WORKDIR /app
Removing intermediate container 514c8c3f5511
---> d8611af96ced
Step 5/15 : RUN npm install
---> Running in e635ea2d39be
.
.
.
Step 13/15 : EXPOSE 3000
---> Running in f246b51e0a0f
Removing intermediate container f246b51e0a0f
---> 39b74e2eda59
Step 14/15 : ENTRYPOINT ["node"]
---> Running in 4fa38e6c2d19
Removing intermediate container 4fa38e6c2d19
---> ee6c549f88ca
Step 15/15 : CMD ["app.js", "--sslkey", "key.pem", "--sslcert", "cert.pem", "-p", "3000"]
---> Running in 26c1f3817918
Removing intermediate container 26c1f3817918
---> f69d767e6c92
Successfully built f69d767e6c92
Successfully tagged demo/wetty:latest

Spin Up a Container

$ sudo docker run --name termdemo -p 3000:3000 -dt demo/wetty

Test Your Wetty

Image for post
Image for post

Tips

References

Related

Chairat.me

Personal blog of a developer who passionate in new…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store