Current article: https://blog.digitaloak.it/en/posts/create-development-env
AWS Cloud9 is an accessible via web browser IDE with full access to the machine with installed Linux distribution (EC2 instance or your server) and with built in many features.
You can read more about it here https://aws.amazon.com/cloud9/ and about pricing here https://aws.amazon.com/cloud9/pricing/. Below screenshot presenting editor.
It’s handy to run development environment, share workspace with other developers and publish work for external or internal preview.
In our example we will use Node-RED docker image and AWS EC2 t2.micro instance. Let’s split work into multiple parts:
Last two are optional and important if you want share access to your services. First option is about mapping port from EC2 to service (in this example to Node-RED docker container), second is the same as first but relates only to VNC service from which you have access to all services in your docker virtual network.
It is also possible to share your AWS Cloud9 workspace using its built in functionality.
Go to Cloud9 service and Create environment > Create a new instance for environment (EC2); Select Amazon Linux > Next step > Create environment
For our development purpose we need access to two Node-RED container folders from host (Cloud9 editor):
To achieve it, we will run container, copy to host specified above two folders, remove container and again start it with mounted, previously copied folders. Then we will modify permissions for container "node-red" user to have same UID and GID as host user.
docker network create --driver bridge pink --subnet 172.30.0.0/16
docker run -d -ti \
--name node-red \
--restart always \
-p 8080:1880 \
nodered/node-red:latest
docker cp -a -L node-red:/data /home/ec2-user/environment
docker cp -a -L node-red:/usr/src/node-red /home/ec2-user/environment
docker rm -f node-red
docker run -ti -d \
--name node-red \
--hostname node-red \
--mount type=bind,source=/home/ec2-user/environment/data,target=/data \
--mount type=bind,source=/home/ec2-user/environment/node-red,target=/usr/src/node-red \
--restart always \
--net pink \
--ip 172.30.0.11 \
-p 8080:1880 \
nodered/node-red:latest
docker exec -ti -u root node-red bash
echo http://dl-2.alpinelinux.org/alpine/latest-stable/community/ >> /etc/apk/repositories
apk --no-cache add shadow
usermod -u 501 node-red
groupmod -g 501 node-red
find / -user 1000 -exec chown -h node-red {} \;
find / -group 1000 -exec chgrp -h node-red {} \;
exit
docker restart node-red
editorTheme: {
projects: {
// To enable the Projects feature, set this value to true
enabled: true
}
}
docker restart node-red
To open Node-RED flow editor (http service is listening on 8080), click “Preview” > “Preview Running Application”. Open URL in browser of your choice.
Now you can access it using EC2 instance public domain with enabled port.
docker run \
-it \
--name vnc \
-p 8081:80 \
-v /dev/shm:/dev/shm \
--net pink \
-e RESOLUTION=800x600 \
-e VNC_PASSWORD=Upd4t34lm4n4ch \
--ip 172.30.0.16 \
-d dorowu/ubuntu-desktop-lxde-vnc
Video is also available on
Problem: Error when installing c9 on remote machine with Debian Stretch “tmux: need UTF-8 locale (LC_CTYPE) but have ANSI_X3.4–1968”
Solution: install package locales-all