mirror of
https://github.com/bluxmit/alnoda-workspaces.git
synced 2024-05-16 03:52:19 +12:00
release 2.0: go-workspace
This commit is contained in:
parent
fdae75bf94
commit
d76180200a
26
workspaces/go-workspace/Dockerfile
Normal file
26
workspaces/go-workspace/Dockerfile
Normal file
|
@ -0,0 +1,26 @@
|
|||
ARG docker_registry=docker.io/alnoda
|
||||
ARG image_tag=2.0
|
||||
ARG ruby_global_version=3.1.2
|
||||
|
||||
FROM ${docker_registry}/codeserver-workspace:${image_tag}
|
||||
USER root
|
||||
|
||||
COPY docs/getting-started.md /home/docs/docs/getting-started.md
|
||||
|
||||
RUN apt-get -y update \
|
||||
&& echo "------------------------------------------------------ go " \
|
||||
&& cd /tmp && curl -LO https://go.dev/dl/go1.18.2.linux-amd64.tar.gz \
|
||||
&& tar -xvf go1.18.2.linux-amd64.tar.gz -C /usr/local \
|
||||
&& rm /tmp/go1.18.2.linux-amd64.tar.gz \
|
||||
&& echo "------------------------------------------------------ user" \
|
||||
&& find /home -type d | xargs -I{} chown -R abc {} \
|
||||
&& find /home -type f | xargs -I{} chown abc {}
|
||||
|
||||
ENV PATH="$PATH:/usr/local/go/bin"
|
||||
ENV PATH="$PATH:/root/go/bin"
|
||||
ENV PATH="$PATH:/home/abc/go/bin"
|
||||
|
||||
USER abc
|
||||
|
||||
|
||||
|
59
workspaces/go-workspace/README.md
Normal file
59
workspaces/go-workspace/README.md
Normal file
|
@ -0,0 +1,59 @@
|
|||
<p align="center">
|
||||
<img src="https://github.com/bluxmit/alnoda-workspaces/blob/main/img/Alnoda-white.svg" alt="Alnoda logo" width="150">
|
||||
</p>
|
||||
|
||||
# Go workspace
|
||||
|
||||
Docker image with Go and browser-based VS-Code version.
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/bluxmit/alnoda-workspaces/main/workspaces/codeserver-workspace/img/codeserver-collage-sm.jpg" alt="Collage" width="750">
|
||||
</p>
|
||||
|
||||
## Why this images
|
||||
|
||||
1. If you need self-hosted remote development environment.
|
||||
2. If you want to be one terminal command away from coding in Go.
|
||||
|
||||
## Start
|
||||
|
||||
```
|
||||
docker run --name space-1 -d -p 8020-8035:8020-8035 alnoda/go-workspace
|
||||
```
|
||||
|
||||
and open [localhost:8020](http://localhost:8020) in browser.
|
||||
|
||||
## Features
|
||||
|
||||
- [Go](https://go.dev/)
|
||||
|
||||
**Dev tools:**
|
||||
|
||||
- [**Eclipse Theia**](https://theia-ide.org/docs/) - open source version of popular Visual Studio Code IDE. Theia is trully open-source, has
|
||||
VS-Code extensions and works in browser. This means it can run inside a docker container on local machine or in cloud. A lot of beautiful color themes and many common plugins are already installed to save time.
|
||||
- [**Terminal**](https://github.com/tsl0922/ttyd) - secure browser-based terminal.
|
||||
- [**FileBrowser**](https://github.com/filebrowser/filebrowser) - manage files and folders inside the workspace, and exchange data between local environment and the workspace
|
||||
- [**Cronicle**](https://github.com/jhuckaby/Cronicle) - task scheduler and runner, with a web based front-end UI. It handles both scheduled, repeating and on-demand jobs, targeting any number of worker servers, with real-time stats and live log viewer.
|
||||
- [**Static File Server**](https://github.com/vercel/serve) - view any static html sites as easy as if you do it on your local machine. Serve static websites easily.
|
||||
- [**Ungit**](https://github.com/FredrikNoren/ungit) - rings user friendliness to git without sacrificing the versatility of it.
|
||||
- [**MkDocs**](https://squidfunk.github.io/mkdocs-material/) - create awesome documentation for your project with only markdown.
|
||||
- [**Midnight Commander**](https://midnight-commander.org/) - Feature rich visual file manager with internal text viewer and editor.
|
||||
- [**Process Monitor**](https://htop.dev/) - Monitor running process and resource utilization.
|
||||
- Quicklaunch UI with getting started tutorial
|
||||
|
||||
Image is built from **Ubuntu 20.4** with the additional CLI apps
|
||||
|
||||
- [Zsh](https://www.zsh.org/), [Oh my Zsh](https://ohmyz.sh/)
|
||||
- Python 3, Pip
|
||||
- Node/nodeenv
|
||||
- curl, wget, telnet, jq
|
||||
- **Git:** git, git-flow, lazygit
|
||||
- **File browsers:** mc, xplr
|
||||
- **Text editors:** nano, vim, mcedit
|
||||
- **System monitors:** ncdu, htop, glances, vizex
|
||||
- **Process Control:** supervisord
|
||||
- **Job scheduler:** cron
|
||||
|
||||
## Docs
|
||||
See our guides on [**getting started**](docs/getting-started.md) and [**advanced features**](../ubuntu-workspace/docs/workspaces.md).
|
||||
|
141
workspaces/go-workspace/docs/getting-started.md
Normal file
141
workspaces/go-workspace/docs/getting-started.md
Normal file
|
@ -0,0 +1,141 @@
|
|||
# Getting started
|
||||
|
||||
## Intro
|
||||
|
||||
To start, open Quickstart page [localhost:8020](http://localhost:8020/) for quick access to all the tools
|
||||
|
||||
From the quicklaunch page you can open workspace tools, such as code editor or terminal
|
||||
|
||||
<div align="center" style="font-style: italic;">
|
||||
Demo: Workspace UI
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/bluxmit/alnoda-workspaces/main/workspaces/ide-workspace/img/wid-ui.png" alt="wid-ui.png" width="750">
|
||||
</p>
|
||||
|
||||
The main code editor of this workspace is [Code-server](https://github.com/cdr/code-server)
|
||||
|
||||
<div align="center" style="font-style: italic;">
|
||||
Demo: Code-server
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/bluxmit/alnoda-workspaces/main/workspaces/codeserver-workspace/img/codeserver-demo.gif" alt="Code-server demo" width="900">
|
||||
</p>
|
||||
|
||||
Workspace has full-size browser-base terminal
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/bluxmit/alnoda-workspaces/main/workspaces/base-workspace/img/base-workspace-terminal.gif" alt="Base-Workspace terminal" width="750">
|
||||
</p>
|
||||
|
||||
## Example: hello world
|
||||
|
||||
Check Go version
|
||||
|
||||
```
|
||||
go version
|
||||
```
|
||||
|
||||
Create new Go project
|
||||
|
||||
```
|
||||
mkdir myProject/
|
||||
cd myProject
|
||||
go mod init myProject
|
||||
```
|
||||
|
||||
Create file `main.go`
|
||||
|
||||
```
|
||||
package main
|
||||
import "fmt"
|
||||
func main() {
|
||||
fmt.Println("Hello Go")
|
||||
}
|
||||
```
|
||||
|
||||
Then test it using the go run command
|
||||
|
||||
```
|
||||
go run main.go
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
Go Modules - Go’s dependency management system that makes dependency version information explicit and easier to manage.
|
||||
|
||||
Create new Go project
|
||||
|
||||
```
|
||||
mkdir simpleserver/
|
||||
cd simpleserver
|
||||
go mod init simpleserver
|
||||
```
|
||||
|
||||
Adding a remote module as a dependency manually:
|
||||
|
||||
```
|
||||
go get github.com/spf13/cobra@latest
|
||||
```
|
||||
|
||||
Check `go.mod` file
|
||||
|
||||
```
|
||||
cat go.mod
|
||||
```
|
||||
|
||||
Create file `main.go`
|
||||
|
||||
```
|
||||
package main
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
r.GET("/ping", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"message": "pong",
|
||||
})
|
||||
})
|
||||
r.Run()
|
||||
}
|
||||
```
|
||||
|
||||
To add module requirements and sums execute
|
||||
|
||||
```
|
||||
go mod tidy
|
||||
```
|
||||
|
||||
Run the simple server with
|
||||
|
||||
```
|
||||
export PORT=8030
|
||||
go run main.go
|
||||
```
|
||||
|
||||
Open in browser [localhost:8030/ping](http://localhost:8030/ping)
|
||||
|
||||
Build executable locally
|
||||
|
||||
```
|
||||
go build
|
||||
```
|
||||
|
||||
This will create an executable `simpleserver` in the same folder.
|
||||
|
||||
Build and move to executable folder
|
||||
|
||||
```
|
||||
go install
|
||||
```
|
||||
|
||||
Now you can execute anywhere in terminal
|
||||
|
||||
```
|
||||
simpleserver
|
||||
```
|
||||
|
||||
and the server will start
|
BIN
workspaces/go-workspace/img/serve-website.png
Normal file
BIN
workspaces/go-workspace/img/serve-website.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
|
@ -13,7 +13,7 @@ Docker image with Node.js and browser-based VS-Code version.
|
|||
## Why this images
|
||||
|
||||
1. If you need self-hosted development environment.
|
||||
2. If you want to be one command away from coding in JavaScript.
|
||||
2. If you want to be one terminal command away from coding in JavaScript.
|
||||
|
||||
## Start
|
||||
|
||||
|
@ -25,9 +25,9 @@ and open [localhost:8020](http://localhost:8020) in browser.
|
|||
|
||||
## Features
|
||||
|
||||
- Node 18.1.0
|
||||
- Npm 8.8.0
|
||||
- Yarn 1.22.18
|
||||
- Node
|
||||
- Npm
|
||||
- Yarn
|
||||
- [Nvm](https://github.com/nvm-sh/nvm)
|
||||
- [Nodeenv](https://pypi.org/project/nodeenv/)
|
||||
|
||||
|
|
|
@ -9,16 +9,28 @@ COPY docs/getting-started.md /home/docs/docs/getting-started.md
|
|||
RUN apt-get -y update \
|
||||
&& echo "------------------------------------------------------ rbenv (root) " \
|
||||
&& wget -q https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer -O- | bash \
|
||||
&& echo 'PATH="/home/abc/.rbenv/bin:$PATH"' >> /root/.zshrc \
|
||||
&& echo "------------------------------------------------------ ruby (system) " \
|
||||
&& echo 'PATH="/root/.rbenv/bin:$PATH"' >> /root/.zshrc \
|
||||
&& echo 'eval "$(rbenv init -)"' >> /root/.zshrc \
|
||||
&& export PATH="/root/.rbenv/bin:$PATH" \
|
||||
&& echo "------------------------------------------------------ ruby (system global) " \
|
||||
&& apt-get install -y build-essential libssl-dev libyaml-dev zlib1g-dev libffi-dev \
|
||||
&& /root/.rbenv/bin/rbenv install 3.1.2
|
||||
&& rbenv install 3.1.2 \
|
||||
&& rbenv global 3.1.2 \
|
||||
&& /root/.rbenv/shims/gem install bundler \
|
||||
&& echo "------------------------------------------------------ user" \
|
||||
&& find /home -type d | xargs -I{} chown -R abc {} \
|
||||
&& find /home -type f | xargs -I{} chown abc {}
|
||||
|
||||
USER abc
|
||||
|
||||
RUN echo "------------------------------------------------------ rbenv (abc) " \
|
||||
&& wget -q https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer -O- | bash \
|
||||
&& echo 'PATH="/home/abc/.rbenv/bin:$PATH"' >> /home/abc/.zshrc
|
||||
&& echo 'PATH="/home/abc/.rbenv/bin:$PATH"' >> /home/abc/.zshrc \
|
||||
&& echo 'eval "$(rbenv init -)"' >> /home/abc/.zshrc \
|
||||
&& export PATH="/home/abc/.rbenv/bin:$PATH" \
|
||||
&& rbenv install 3.1.2 \
|
||||
&& rbenv global 3.1.2 \
|
||||
&& /home/abc/.rbenv/shims/gem install bundler
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# Ruby workspace
|
||||
|
||||
Docker image with
|
||||
Docker image with Ruby and browser-based VS-Code version.
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/bluxmit/alnoda-workspaces/main/workspaces/codeserver-workspace/img/codeserver-collage-sm.jpg" alt="Collage" width="750">
|
||||
|
@ -13,7 +13,7 @@ Docker image with
|
|||
## Why this images
|
||||
|
||||
1. If you need self-hosted remote development environment.
|
||||
2. If you want to be one command away from coding in Ruby.
|
||||
2. If you want to be one terminal command away from coding in Ruby.
|
||||
|
||||
## Start
|
||||
|
||||
|
@ -25,7 +25,9 @@ and open [localhost:8020](http://localhost:8020) in browser.
|
|||
|
||||
## Features
|
||||
|
||||
-
|
||||
- [Ruby](https://www.ruby-lang.org/)
|
||||
- [Rbennv](https://github.com/rbenv/rbenv)
|
||||
- [Bundler](https://bundler.io/)
|
||||
|
||||
**Dev tools:**
|
||||
|
||||
|
|
|
@ -30,61 +30,108 @@ Workspace has full-size browser-base terminal
|
|||
<img src="https://raw.githubusercontent.com/bluxmit/alnoda-workspaces/main/workspaces/base-workspace/img/base-workspace-terminal.gif" alt="Base-Workspace terminal" width="750">
|
||||
</p>
|
||||
|
||||
## Ruby
|
||||
|
||||
## Hello World
|
||||
|
||||
Check PHP version
|
||||
Check Ruby version
|
||||
|
||||
```
|
||||
php -v
|
||||
ruby -v
|
||||
```
|
||||
|
||||
Open IDE and create file `hello.php` with the following content
|
||||
Install Rails - a web application development framework written in the Ruby programming language.
|
||||
|
||||
```
|
||||
<html>
|
||||
<head>
|
||||
<title>PHP Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php echo '<p>Hello World</p>'; ?>
|
||||
</body>
|
||||
</html>
|
||||
gem install rails
|
||||
```
|
||||
|
||||
Start server in terminal
|
||||
Check version
|
||||
|
||||
```
|
||||
cd /home/project
|
||||
php -S 127.0.0.1:8030
|
||||
rails --version
|
||||
```
|
||||
|
||||
Open [localhost:8030/hello.php](http://localhost:8030/hello.php) in browser
|
||||
## Bundler
|
||||
|
||||
## Website example
|
||||
|
||||
Clone GitHub repo with a PHP website, for example
|
||||
Create file `Gemfile` with the following content
|
||||
|
||||
```
|
||||
git clone https://github.com/banago/simple-php-website.git
|
||||
source 'https://rubygems.org'
|
||||
gem 'nokogiri'
|
||||
gem 'rack', '~> 2.0.1'
|
||||
gem 'rspec'
|
||||
```
|
||||
|
||||
Server with PHP development server
|
||||
Install all of the required gems
|
||||
|
||||
```
|
||||
cd simple-php-website
|
||||
php -S 0.0.0.0:8030
|
||||
bundle install
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/bluxmit/alnoda-workspaces/main/workspaces/php-workspace/img/serve-website.png" alt="serve-website" width="500">
|
||||
</p>
|
||||
## Rbenv
|
||||
|
||||
# Composer
|
||||
Use [rbenv](https://github.com/rbenv/rbenv) to pick a Ruby version for your application and guarantee that your development environment matches production.
|
||||
|
||||
Install package with Composer
|
||||
List available versions, and install another one
|
||||
|
||||
```
|
||||
composer require phpunit/php-timer
|
||||
rbenv install --list
|
||||
rbenv install 3.0.4
|
||||
```
|
||||
|
||||
Lists all Ruby versions known to rbenv, and shows an asterisk next to the currently active version.
|
||||
|
||||
```
|
||||
rbenv versions
|
||||
```
|
||||
|
||||
__global environment__
|
||||
|
||||
|
||||
Change global Ruby (for all folders)
|
||||
|
||||
```
|
||||
rbenv global 3.0.4
|
||||
```
|
||||
|
||||
__local environment (specific folder)__
|
||||
|
||||
Chose local Ruby environment for this specific folder
|
||||
|
||||
```
|
||||
rbenv local 3.0.4
|
||||
```
|
||||
|
||||
## Basic example
|
||||
|
||||
Create file `http_server.rb`
|
||||
|
||||
```rb
|
||||
# http_server.rb
|
||||
require 'socket'
|
||||
server = TCPServer.new 8030
|
||||
|
||||
while session = server.accept
|
||||
request = session.gets
|
||||
puts request
|
||||
|
||||
session.print "HTTP/1.1 200\r\n" # 1
|
||||
session.print "Content-Type: text/html\r\n" # 2
|
||||
session.print "\r\n" # 3
|
||||
session.print "Hello world! The time is #{Time.now}" #4
|
||||
|
||||
session.close
|
||||
end
|
||||
```
|
||||
|
||||
Serve simple server
|
||||
|
||||
```
|
||||
ruby http_server.rb
|
||||
```
|
||||
|
||||
Open browser on [localhost:8030](http://localhost:8030/)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue