How elegant in the Internet cafe to knock code

primers

Internet cafe this word for most of us after 90 boys may represent the youth can never go back, whenever speaking of Internet cafes can always recall too many memories, today’s Internet cafes are still full of the streets and alleys of the town, but at that time together on the Internet cafe people are difficult to get together. Secondly, now that everyone basically has their own PC, the number of times to go to the Internet bar is only a handful, and basically on holidays, we will get together in the Internet bar. Now around friends or colleagues are basic programmers, play games less, whenever talking about the Internet cafe, everyone is joking to the Internet cafe together to knock code, then the question comes, how elegant in the Internet cafe knock code?

code-server

While surfing the Internet recently, I came across an interesting project called Code-Server

Code-server Project address: github.com/cdr/code-se…

Code – server is what? The first sentence of the project is

Run VS Code on any machine anywhere and access it in the browser.

VS Code, which translates to running VS Code on any machine as accessed in a browser, is known to be an open source IDE built on Electron (I actually didn’t know 😅 for a long time).

Electron: Build cross-platform desktop applications using JavaScript, HTML, and CSS

Some people look at this and say, well, since VS Code is built using JavaScript, HTML, and CSS, if you fiddle with it, you can run it in a browser, and then somebody did, and this project was code-Server, It’s currently on Github with 46.7K of Star, which is a good indication of its popularity.

Code – server deployment

The deployment of code-server is also simple, as described on the project home page, with a single command to install

To install, run:

curl -fsSL https://code-server.dev/install.sh | sh
Copy the code

However, to avoid file pollution, download instability and convenient management, Docker is still recommended for deployment

Docker deployment code – server

Deployment of words you can also write Dockerfile according to their actual demand, of course the lazy or recommend you use someone else to write good have uploaded images, after try on my side, feel is a relatively good image of linuxserver/dockercodeserver

Project address: github.com/linuxserver…

So here we’re using docker-compose to run the Docker container

docker-compose.yml

version: "2.1"
services:
  code-server:
    image: linuxserver/code-server
    container_name: code-server
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Shanghai
      - PASSWORD=123456 # Password to access the site (use your own password)
      - SUDO_PASSWORD=123456 Use sudo's password in terminal (use your own password)
      - HASHED_PASSWORD= #optional
    volumes:
      - /root/code-server/config:/config
    ports:
      - 8443: 8443
    restart: unless-stopped
Copy the code

Notes:

  • PASSWORDIt’s the password to the site
  • SUDO_PASSWORDIs the password to use sudo on the terminal
  • Select a directory and mount it to the container. The image will create a new user in the container. The directory you set to mount will be the user directory of that user.VS CodeThis directory will be the working directory
  • The image is already installedGit,Node.js,Npm,YarnSuch as software packages, front-end practitioners can take the basic can be directly developed, if you need other software packages please install
  • It is best to usehttpsDeploy, if usinghttpThere are many limitations to deployment

  • Remember to configuredevServerEnable extranet access
devServer: {
	/ / other slightly
    port: 9000./ / port
    host: '0.0.0.0'.// The server is externally accessible
    allowedHosts: [ // Allowed host addresses
      '.xikcloud.com']},Copy the code
Use the Git

run

ssh-keygen -o
Copy the code

Create the SSH public key, which is stored in.ssh/id_rsa.pub by default, and add the public key to your Github account

The final result

Finally answer the previous question, how elegant in the Internet cafe to knock code? No need to configure any environment, open the computer, open the browser, enter the url, everything is ready, this is elegant!