Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Rodgers committed Oct 21, 2019
0 parents commit 44e18cd
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/tmp/
/local/
34 changes: 34 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
before_script:
- docker info
- '[ -d tmp ] || mkdir tmp'
- git clone https://github.com/OSC/ondemand-packaging.git tmp/ondemand-packaging
- cp /systems/osc_certs/gpg/ondemand/.gpgpass $CI_PROJECT_DIR/tmp/ondemand-packaging/
- cp /systems/osc_certs/gpg/ondemand/ondemand.sec $CI_PROJECT_DIR/tmp/ondemand-packaging/
stages:
- build
- deploy

rpm-build:
stage: build
only:
- tags
script:
- ./tmp/ondemand-packaging/build.sh -w $CI_PROJECT_DIR/tmp/work -o $CI_PROJECT_DIR/tmp/output -V $CI_COMMIT_TAG -u -v $CI_PROJECT_DIR/packaging
artifacts:
paths:
- tmp/output
name: "$CI_PROJECT_NAME-$CI_COMMIT_TAG"


rpm-deploy:
variables:
RLS_SCRIPT: "./tmp/ondemand-packaging/release.py"
RLS_KEY: "/systems/osc_certs/ssh/ondemand-packaging/id_rsa"
RLS_OUTPUT: "./tmp/output/*"
SECTION: "main"
stage: deploy
only:
- tags
script:
- if [[ "$CI_COMMIT_TAG" =~ .*_.* ]]; then export SECTION=ci; fi
- $RLS_SCRIPT --debug --pkey $RLS_KEY -c $SECTION $RLS_OUTPUT
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.0.1] - 2019-10-21
### Added
- Initial release
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2016-2019 Ohio Supercomputer Center

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Batch Connect - OSC Code Server

![GitHub Release](https://img.shields.io/github/release/osc/bc_osc_codeserver.svg)
[![GitHub License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)

An improved file viewer / editor for OSC OnDemand that launches a
Code Server within an Owens batch job. Code Server leverages VSCode as its
editor.

## Prerequisites

This Batch Connect app requires the following software be installed on the
**compute nodes** that the batch job is intended to run on (**NOT** the
OnDemand node):

- [Lmod] 6.0.1+ or any other `module purge` and `module load <modules>` based
CLI used to load appropriate environments within the batch job before
launching Code server.
- [Code Server] 2.x+ available from Github: https://github.com/cdr/code-server/releases

[Code Server]: https://coder.com/
[Lmod]: https://www.tacc.utexas.edu/research-development/tacc-projects/lmod
[VS Code]: https://code.visualstudio.com/

## Install

Use Git to clone this app and checkout the desired branch/version you want to
use:

```sh
scl enable git29 -- git clone <repo>
cd <dir>
scl enable git29 -- git checkout <tag/branch>
```

You will not need to do anything beyond this as all necessary assets are
installed. You will also not need to restart this app as it isn't a Passenger
app.

To update the app you would:

```sh
cd <dir>
scl enable git29 -- git fetch
scl enable git29 -- git checkout <tag/branch>
```

Again, you do not need to restart the app as it isn't a Passenger app.

## Contributing

1. Fork it ( https://github.com/OSC/bc_osc_codeserver/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Known Issues

- In-app installation of extensions does not work
6 changes: 6 additions & 0 deletions form.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions form.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
cluster: "quick"
form:
- bc_account
- bc_num_hours
- working_dir
attributes:
working_dir:
label: "Working Directory"
data-filepicker: true
readonly: false
help: "Select your project directory; defaults to $HOME"
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Code Server
category: Interactive Apps
subcategory: Servers
role: batch_connect
description: |
This app will launch a [VS Code] server using [Code Server] on the [Owens
cluster].
[VS Code]: https://code.visualstudio.com/
[Code Server]: https://coder.com/
[Owens cluster]: https://www.osc.edu/resources/technical_support/supercomputers/owens
49 changes: 49 additions & 0 deletions packaging/ondemand-bc_osc_codeserver.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Disable debuginfo as it causes issues with bundled gems that build libraries
%global debug_package %{nil}
%global repo_name bc_osc_codeserver
%global app_name bc_osc_codeserver
%{!?package_version: %define package_version %{major}.%{minor}.%{patch}}
%{!?package_release: %define package_release 1}
%{!?git_tag: %define git_tag v%{package_version}}
%define git_tag_minus_v %(echo %{git_tag} | sed -r 's/^v//')

Name: ondemand-%{app_name}
Version: %{package_version}
Release: %{package_release}%{?dist}
Summary: Batch Connect - OSC Code Server

Group: System Environment/Daemons
License: MIT
URL: https://github.com/OSC/%{repo_name}
Source0: https://github.com/OSC/%{repo_name}/archive/%{git_tag}.tar.gz

Requires: ondemand

# Disable automatic dependencies as it causes issues with bundled gems and
# node.js packages used in the apps
AutoReqProv: no

%description
An interactive app designed for OSC OnDemand that launches a Code Server within an Owens batch job.


%prep
%setup -q -n %{repo_name}-%{git_tag_minus_v}


%build


%install
%__mkdir_p %{buildroot}%{_localstatedir}/www/ood/apps/sys/%{app_name}
%__cp -a ./. %{buildroot}%{_localstatedir}/www/ood/apps/sys/%{app_name}/
echo v%{version} > %{buildroot}%{_localstatedir}/www/ood/apps/sys/%{app_name}/VERSION


%files
%defattr(-,root,root)
%{_localstatedir}/www/ood/apps/sys/%{app_name}
%{_localstatedir}/www/ood/apps/sys/%{app_name}/manifest.yml


%changelog
7 changes: 7 additions & 0 deletions submit.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
batch_connect:
template: "basic"
script:
native:
resources:
nodes: "1:ppn=1:owens"
9 changes: 9 additions & 0 deletions template/after.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Wait for the Jupyter server to start
echo "Waiting for Jupyter server to open port ${port}..."
if wait_until_port_used "${host}:${port}" 600; then
echo "Discovered code-server listening on port ${port}!"
else
echo "Timed out waiting for Jupyter server to open port ${port}!"
clean_up 1
fi
sleep 2
8 changes: 8 additions & 0 deletions template/before.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# # Export the module function if it exists
[[ $(type -t module) == "function" ]] && export -f module

# # Find available port to run server on
export port=$(find_port ${host})

# # Generate SHA1 encrypted password (requires OpenSSL installed)
export password="$(create_passwd 16)"
29 changes: 29 additions & 0 deletions template/script.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
<%-
working_dir = Pathname.new(context.working_dir)
if ! working_dir.exist? || working_dir.to_s.empty?
working_dir = Pathname.new(ENV['HOME'])
elsif working_dir.file?
working_dir = working_dir.parent
end
%>

# Ensure a dataroot for Code Server
CODE_SERVER_DATAROOT="$HOME/.local/share/bc_osc_codeserver"
mkdir -p "$CODE_SERVER_DATAROOT/extensions"

export PASSWORD="$password"

# VSCode complains that system git is too old
module load git

#
# Start Code Server
#

/fs/project/PZS0714/mrodgers/bin/code-server-2.1523-vsc1.38.1 \
--auth=password \
--port="$port" \
--extra-extensions-dir="$CODE_SERVER_DATAROOT/extensions" \
--user-data-dir="$CODE_SERVER_DATAROOT" \
"<%= working_dir.to_s %>"
6 changes: 6 additions & 0 deletions view.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<form action="/rnode/<%= host %>/<%= port %>/login" method="post" target="_blank">
<input type="hidden" name="password" value="<%= password %>">
<button class="btn btn-primary" type="submit">
<i class="fa fa-cogs"></i> Connect to Code Server
</button>
</form>

0 comments on commit 44e18cd

Please sign in to comment.