mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-22 12:24:25 +00:00
Merge branch 'sorenisanerd:master' into master
This commit is contained in:
commit
9224e98568
36
.github/workflows/pre-release.yaml
vendored
Normal file
36
.github/workflows/pre-release.yaml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
name: "pre-release"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pre-release-docker:
|
||||||
|
name: "Pre Release Docker"
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: "${{ secrets.DOCKER_HUB_USER }}"
|
||||||
|
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
|
||||||
|
|
||||||
|
- name: "Build and push docker image"
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: "${{ secrets.DOCKER_REPO }}:latest"
|
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"amodio.tsl-problem-matcher"
|
||||||
|
]
|
||||||
|
}
|
15
.vscode/launch.json
vendored
15
.vscode/launch.json
vendored
@ -7,10 +7,21 @@
|
|||||||
{
|
{
|
||||||
"name": "Launch GoTTY",
|
"name": "Launch GoTTY",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
|
"buildFlags": "-tags=dev",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "${workspaceFolder}",
|
"program": "${workspaceFolder}",
|
||||||
"args": ["-a", "127.0.0.1", "-w", "bash"]
|
"args": ["-a", "127.0.0.1", "-w", "${env:SHELL}"]
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"name": "Launch Chrome",
|
||||||
|
"type": "chrome",
|
||||||
|
"url": "http://127.0.0.1:8080",
|
||||||
|
"webRoot": "${workspaceFolder}/js",
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/**/*.js",
|
||||||
|
"!**/node_modules/**"
|
||||||
|
],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
16
.vscode/tasks.json
vendored
Normal file
16
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "webpack watch",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "cd ${workspaceFolder}/js;DEV=1 npx webpack --watch --mode=development",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$ts-webpack-watch"
|
||||||
|
],
|
||||||
|
"isBackground": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
Dockerfile
15
Dockerfile
@ -1,15 +1,20 @@
|
|||||||
FROM golang:1.16
|
FROM node:16 as js-build
|
||||||
|
WORKDIR /gotty
|
||||||
|
COPY js /gotty/js
|
||||||
|
COPY Makefile /gotty/
|
||||||
|
RUN make bindata/static/js/gotty.js.map
|
||||||
|
|
||||||
|
FROM golang:1.16 as go-build
|
||||||
WORKDIR /gotty
|
WORKDIR /gotty
|
||||||
COPY . /gotty
|
COPY . /gotty
|
||||||
|
COPY --from=js-build /gotty/js/node_modules /gotty/js/node_modules
|
||||||
|
COPY --from=js-build /gotty/bindata/static/js /gotty/bindata/static/js
|
||||||
RUN CGO_ENABLED=0 make
|
RUN CGO_ENABLED=0 make
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk upgrade && \
|
apk upgrade && \
|
||||||
apk --no-cache add ca-certificates && \
|
apk --no-cache add ca-certificates bash
|
||||||
apk add bash
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
COPY --from=0 /gotty/gotty /usr/bin/
|
COPY --from=go-build /gotty/gotty /usr/bin/
|
||||||
CMD ["gotty", "-w", "bash"]
|
CMD ["gotty", "-w", "bash"]
|
||||||
|
11
Makefile
11
Makefile
@ -2,13 +2,20 @@ OUTPUT_DIR = ./builds
|
|||||||
GIT_COMMIT = `git rev-parse HEAD | cut -c1-7`
|
GIT_COMMIT = `git rev-parse HEAD | cut -c1-7`
|
||||||
VERSION = $(shell git describe --tags)
|
VERSION = $(shell git describe --tags)
|
||||||
BUILD_OPTIONS = -ldflags "-X main.Version=$(VERSION)"
|
BUILD_OPTIONS = -ldflags "-X main.Version=$(VERSION)"
|
||||||
WEBPACK_MODE = production
|
|
||||||
|
ifeq ($(DEV), 1)
|
||||||
|
BUILD_OPTIONS += -tags dev
|
||||||
|
WEBPACK_MODE = development
|
||||||
|
else
|
||||||
|
WEBPACK_MODE = production
|
||||||
|
endif
|
||||||
|
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
|
|
||||||
gotty: main.go assets server/*.go webtty/*.go backend/*.go Makefile
|
gotty: main.go assets server/*.go webtty/*.go backend/*.go Makefile
|
||||||
go build ${BUILD_OPTIONS}
|
go build ${BUILD_OPTIONS}
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
docker build . -t gotty-bash:$(VERSION)
|
docker build . -t gotty-bash:$(VERSION)
|
||||||
|
|
||||||
.PHONY: all docker assets
|
.PHONY: all docker assets
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build !dev
|
||||||
|
|
||||||
package bindata
|
package bindata
|
||||||
|
|
||||||
import "embed"
|
import "embed"
|
||||||
|
28
bindata/bindata_dev.go
Normal file
28
bindata/bindata_dev.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
//go:build dev
|
||||||
|
|
||||||
|
package bindata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"io/fs"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GottyFS struct {
|
||||||
|
fs.FS
|
||||||
|
}
|
||||||
|
|
||||||
|
var Fs GottyFS
|
||||||
|
|
||||||
|
func (gfs *GottyFS) ReadFile(name string) ([]byte, error) {
|
||||||
|
fp, err := gfs.Open(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return io.ReadAll(fp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Fs = GottyFS{os.DirFS("bindata")}
|
||||||
|
}
|
2876
js/package-lock.json
generated
2876
js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,8 @@
|
|||||||
"ts-loader": "^8.3.0",
|
"ts-loader": "^8.3.0",
|
||||||
"typescript": "^4.3.2",
|
"typescript": "^4.3.2",
|
||||||
"webpack": "^5.72.0",
|
"webpack": "^5.72.0",
|
||||||
"webpack-cli": "^4.7.0"
|
"webpack-cli": "^4.7.0",
|
||||||
|
"webpack-dev-server": "^4.11.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@popperjs/core": "^2.11.5",
|
"@popperjs/core": "^2.11.5",
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules",
|
||||||
|
"dist"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,14 @@ const path = require('path');
|
|||||||
const TerserPlugin = require("terser-webpack-plugin");
|
const TerserPlugin = require("terser-webpack-plugin");
|
||||||
const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
|
const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
|
||||||
|
|
||||||
|
var devtool;
|
||||||
|
|
||||||
|
if (process.env.DEV === '1') {
|
||||||
|
devtool = 'inline-source-map';
|
||||||
|
} else {
|
||||||
|
devtool = 'source-map';
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: "./src/main.ts",
|
entry: "./src/main.ts",
|
||||||
entry: {
|
entry: {
|
||||||
@ -10,7 +18,7 @@ module.exports = {
|
|||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, '../bindata/static/js/'),
|
path: path.resolve(__dirname, '../bindata/static/js/'),
|
||||||
},
|
},
|
||||||
devtool: "source-map",
|
devtool: devtool,
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".tsx", ".js"],
|
extensions: [".ts", ".tsx", ".js"],
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,12 @@ func (wt *WebTTY) Run(ctx context.Context) error {
|
|||||||
errs <- func() error {
|
errs <- func() error {
|
||||||
buffer := make([]byte, wt.bufferSize)
|
buffer := make([]byte, wt.bufferSize)
|
||||||
for {
|
for {
|
||||||
n, err := wt.slave.Read(buffer)
|
//base64 length
|
||||||
|
effectiveBufferSize := wt.bufferSize - 1
|
||||||
|
//max raw data length
|
||||||
|
maxChunkSize := int(effectiveBufferSize/4) * 3
|
||||||
|
|
||||||
|
n, err := wt.slave.Read(buffer[:maxChunkSize])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrSlaveClosed
|
return ErrSlaveClosed
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user