This is the 15th day article of Advent Calender on the 2019 code-server.
Continuing from the last time, I would like to launch EC2 Instance.
table of contents Local environment 1st day Online environment version 1st day Improve work environment
Online environment, day 2 Create a virtual network
Online environment 3rd day Launch an EC2 instance with Boto3
Online environment 4th day Try running Code-Server in the cloud
Online environment 5th day Launch code-server on Docker
Online environment, day 6 Let's automate
Online environment 7th day Deploy compute on git on EC2
... Online version .. Built with Coompose file
Online .. Try K8S
...
Demon remodeling
Up to the last time, we have launched EC2 Instance with boto3 x python. Then I ran Code-Server.
This time, let's start Code-Server using Docker.
From the last continuation
$ git clone https://github.com/kyorohiro/advent-2019-code-server.git
$ cd advent-2019-code-server/remote_cs04/
$ docker-compose build
$ docker-compose up -d
In your browser, open http://127.0.0.1:8443/
.
On Terminal
Terminal
$ pip install -r requirements.txt
$ aws configure
..
..
Create EC2Instance
$ python main.py --create
Get EC2 information
$ python main.py --get
>>>> i-0d1e7775a07bbb326
>>>>
>>>> 3.112.18.33
>>>> ip-10-1-0-228.ap-northeast-1.compute.internal
>>>> 10.1.0.228
>>>> {'Code': 16, 'Name': 'running'}
$ chmod 600 advent-code-server.pem
$ ssh -i advent-code-server.pem [email protected]
I will create a Docker environment
On EC2
$ sudo apt-get update
$ sudo apt-get install -y docker.io
$ sudo docker run hello-world
atest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
$ mkdir -p ${HOME}/.local/share/code-server/extensions
$ sudo docker run -it -p 0.0.0.0:8080:8080 -p0.0.0.0:8443:8443 codercom/code-server:v2 --cert
info Server listening on https://0.0.0.0:8080
info - Password is 86821ed9f02ef11d83e980da
info - To use your own password, set the PASSWORD environment variable
info - To disable use `--auth none`
info - Using generated certificate and key for HTTPS
It's done !!
#logout from ec2 instance
$ exit
#local code-On the server
$ python main.py --delete
If you want to reuse it many times, please stop ec2 instance
Let's automate the work that was done manually !!
https://github.com/kyorohiro/advent-2019-code-server/tree/master/remote_cs04
Recommended Posts