Skip to content

Commit 7dde579

Browse files
authored
Create dstack-sshproxy app (#1)
Part-of: dstackai/dstack#3644
1 parent c047fe1 commit 7dde579

File tree

21 files changed

+1416
-0
lines changed

21 files changed

+1416
-0
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
lint:
14+
uses: ./.github/workflows/reusable-lint.yml
15+
build:
16+
uses: ./.github/workflows/reusable-build.yml
17+
with:
18+
version: ${{ github.run_number }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build Binary
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
type: string
8+
required: true
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
- name: Set up Go
16+
uses: actions/setup-go@v6
17+
with:
18+
go-version-file: go.mod
19+
cache-dependency-path: go.sum
20+
- name: Build
21+
run: |
22+
scripts/build.sh build/dstack-sshproxy ${{ inputs.version }}
23+
- id: upload
24+
uses: actions/upload-artifact@v7
25+
with:
26+
name: dstack-sshproxy
27+
path: build/dstack-sshproxy
28+
retention-days: 1
29+
- name: Report
30+
run: |
31+
echo 'version: ${{ inputs.version }}'
32+
echo 'url: ${{ steps.upload.outputs.artifact-url }}'
33+
echo 'digest: ${{ steps.upload.outputs.artifact-digest }}'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Lint Code
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v6
11+
- name: Set up Go
12+
uses: actions/setup-go@v6
13+
with:
14+
go-version-file: go.mod
15+
cache-dependency-path: go.sum
16+
- name: Check go.mod and go.sum
17+
run: go mod tidy -diff
18+
- name: Run golangci-lint
19+
uses: golangci/golangci-lint-action@v9
20+
with:
21+
version: v2.11.3 # Should match .pre-commit-config.yaml
22+
args: --timeout=20m

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
.*
22
!.gitignore
3+
!.github/
4+
!.justfile
5+
!.golangci.yml
6+
!.pre-commit-config.yaml
37

48
build/
59

.golangci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: "2"
2+
3+
linters:
4+
default: none
5+
enable:
6+
- errcheck
7+
- govet
8+
- ineffassign
9+
- staticcheck
10+
- unused
11+
- asciicheck
12+
- bodyclose
13+
- canonicalheader
14+
- errname
15+
- errorlint
16+
- err113
17+
- nilnil
18+
- exhaustive
19+
- modernize
20+
- noctx
21+
- whitespace
22+
23+
formatters:
24+
enable:
25+
- gofumpt
26+
- golines
27+
- goimports
28+
settings:
29+
golines:
30+
max-len: 120
31+
goimports:
32+
local-prefixes:
33+
- github.com/dstackai/sshproxy

.justfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
bin_name := 'dstack-sshproxy'
2+
build_dir := 'build'
3+
4+
[default]
5+
@_list:
6+
just --list --unsorted
7+
8+
@build version='dev':
9+
scripts/build.sh {{build_dir}}/{{bin_name}} {{version}}
10+
11+
@run *args: build
12+
{{build_dir}}/{{bin_name}} {{args}}
13+
14+
@lint:
15+
pre-commit run --files cmd/main.go

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: gomod-fix
5+
name: gomod-fix
6+
entry: go mod tidy
7+
files: ^go\.(mod|sum)$|\.go$
8+
language: unsupported
9+
require_serial: true
10+
pass_filenames: false
11+
- repo: https://github.com/golangci/golangci-lint
12+
rev: v2.11.3 # Should match .github/workflows/reusable-lint.yml
13+
hooks:
14+
- id: golangci-lint-full
15+
language_version: 1.26.0
16+
- id: golangci-lint-fmt
17+
language_version: 1.26.0

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# dstack-sshproxy
2+
3+
## Usage
4+
5+
1. Provide private host keys via `--host-key` (a key file path, may be specified multiple times)
6+
or `$DSTACK_SSHPROXY_HOST_KEYS` (concatenated key files contents). At least one key must be provided.
7+
2. Provide dstack server API token via `--api-token` or `$DSTACK_SSHPROXY_API_TOKEN`.
8+
9+
## Options
10+
11+
```
12+
--address string address for incoming SSH connections (default: all interfaces) [$DSTACK_SSHPROXY_ADDRESS]
13+
--port int port for incoming SSH connections (default: 30022) [$DSTACK_SSHPROXY_PORT]
14+
--host-key string [ --host-key string ] private host key path
15+
--api-url string dstack server API URL (default: "http://localhost:3000") [$DSTACK_SSHPROXY_API_URL]
16+
--api-token string dstack server API token [$DSTACK_SSHPROXY_API_TOKEN]
17+
--api-timeout int timeout of requests to dstack API, seconds (default: 10) [$DSTACK_SSHPROXY_API_TIMEOUT]
18+
--log-level string logging level (default: "info") [$DSTACK_SSHPROXY_LOG_LEVEL]
19+
```
20+
21+
## Build and run locally
22+
23+
```shell
24+
scripts/generate-host-keys.sh > .host_keys
25+
just run --host-key .host-keys --api-token <token> ...
26+
```

0 commit comments

Comments
 (0)