ops/README.md

263 lines
6.5 KiB
Markdown
Raw Normal View History

2019-01-18 04:19:49 +08:00
# OPS
2018-09-12 04:07:08 +08:00
[![CircleCI](https://circleci.com/gh/nanovms/ops.svg?style=svg)](https://circleci.com/gh/nanovms/ops)
[![Go Report](https://goreportcard.com/badge/github.com/nanovms/ops)](https://goreportcard.com/report/github.com/nanovms/ops)
[![Go Docs](https://godoc.org/github.com/nanovms/ops?status.svg)](http://godoc.org/github.com/nanovms/ops)
2019-06-30 03:28:59 +08:00
2019-06-26 07:02:25 +08:00
<p align="center">
<img src="https://i.imgur.com/OtfAABU.png" style="width:200px;"/>
</p>
2019-06-26 06:52:59 +08:00
Ops is a tool for creating and running a [Nanos](https://github.com/nanovms/nanos) unikernel. It is used to
package, create, and run your application as a [nanos](https://github.com/nanovms/nanos) unikernel instance.
2019-01-18 04:19:49 +08:00
1. [Installation](#installation)
2. [Hello World](#hello-world)
3. [Cloud](#cloud)
4. [Support](#support)
Check out the [DOCS](https://nanovms.gitbook.io/ops/).
2019-01-18 04:19:49 +08:00
2019-02-14 05:09:51 +08:00
# Installation
2019-06-26 06:58:46 +08:00
Most users should just download the binary from the website:
2019-02-14 05:09:51 +08:00
## Binary install
```sh
curl https://ops.city/get.sh -sSfL | sh
```
If you don't like this option you can also download pre-made packages
for various systems [here](https://ops.city/downloads) and you can also
build from source.
## Debian / Redhat:
Add a deb src:
```
sudo vi /etc/apt/sources.list.d/fury.list
```
```
deb [trusted=yes] https://apt.fury.io/nanovms/ /
```
Update your sources && install:
```
sudo apt-get update && sudo apt-get install ops
```
2019-05-17 03:12:07 +08:00
## Build and Install from source
2019-02-14 05:09:51 +08:00
2019-06-26 06:58:46 +08:00
Building from source is easy if you have used Go before.
This program requires GO Version 1.13.x or greater.
2019-02-14 05:54:45 +08:00
2019-06-26 06:58:46 +08:00
Installing from source follows these general steps:
2019-02-14 05:09:51 +08:00
2019-06-26 06:58:46 +08:00
Install dependencies:
2019-06-26 07:02:25 +08:00
```sh
make deps
```
2019-06-26 07:02:25 +08:00
Build:
```sh
make build
```
2019-10-31 04:06:44 +08:00
macOS notes:
2019-10-31 04:06:44 +08:00
```sh
2019-10-31 04:06:44 +08:00
GO111MODULE=on go build -ldflags "-w"
```
For [detailed instructions](https://nanovms.gitbook.io/ops/developer/prerequisites), please consult the documentation.
# Hello World
2019-02-14 03:53:29 +08:00
Before learning more about `ops` it is a good idea to see some basic usage
examples. Below are links to simple examples using various programming platforms:
2019-06-26 06:52:59 +08:00
Let's run your first unikernel right now.
2019-07-12 04:06:17 +08:00
[![asciicast](https://asciinema.org/a/256914.svg)](https://asciinema.org/a/256914)
2019-06-26 06:52:59 +08:00
Throw this into hi.js:
```javascript
2021-06-21 22:17:38 +08:00
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
2019-06-26 06:52:59 +08:00
res.end('Hello World\n');
}).listen(8083, "0.0.0.0");
console.log('Server running at http://127.0.0.1:8083/');
```
2019-06-26 06:58:46 +08:00
Then you can run it like so:
```sh
ops pkg load eyberg/node:v16.5.0 -p 8083 -n -a hi.js
2019-06-26 06:52:59 +08:00
```
Note: Since the node package is inside the unikernel you do not need to
install node locally to use it.
2019-11-01 08:07:56 +08:00
# Cloud
2019-11-01 08:07:56 +08:00
Want to push your app out to the cloud? No complex orchestration like
K8S is necessary. OPS pushes all the orchestration onto the cloud
provider of choice so you don't need to manage anything. Be sure to try
this out as the next step after running a hello world locally as it will
answer many questions you might have.
2019-11-01 08:07:56 +08:00
- [Azure](https://docs.ops.city/ops/azure)
- [AWS](https://docs.ops.city/ops/aws)
- [Google Cloud](https://docs.ops.city/ops/google_cloud)
2019-05-17 03:12:07 +08:00
- [Digital Ocean](https://docs.ops.city/ops/digital_ocean)
- [Vultr](https://docs.ops.city/ops/vultr)
- [UpCloud](https://docs.ops.city/ops/upcloud)
2019-05-17 03:12:07 +08:00
You can find many more pre-made packages at the public repo:
2019-05-17 03:12:07 +08:00
[https://repo.ops.city/](https://repo.ops.city/)
2019-01-18 04:19:49 +08:00
Or via the shell:
2019-06-26 06:52:59 +08:00
```sh
2019-06-26 06:52:59 +08:00
ops pkg list
```
You can also upload your own with a free account.
Languages:
Various langauge examples can be found at
[https://github.com/nanovms/ops-examples](https://github.com/nanovms/ops-examples).
In general [https://nanos.org](Nanos) supports any languages and is not
language specific.
You can find more examples and tutorial on youtube as well:
[https://www.youtube.com/channel/UC3mqDqCVu3moVKzmP2YNmlg](https://www.youtube.com/channel/UC3mqDqCVu3moVKzmP2YNmlg)
## Apple M1/M2 Users
The Apple M1 and M2 are ARM based. OPS is built for users primarily
deploying to x86 based servers. While you can certainly run ARM builds
with Nanos and OPS be aware that if you are trying to run x86 builds
(the default) on ARM based M1s you won't be able to use hardware
acceleration for x86.
# Build a bootable image
2019-05-17 03:12:07 +08:00
`ops build <app>`
2019-01-18 04:19:49 +08:00
# Package and run
```sh
ops run <app>
# or
ops run -p <port> <app>
```
2019-01-18 04:19:49 +08:00
2018-10-11 02:15:41 +08:00
# Using a config file
```sh
ops run -p <port> -c <file> <app>
```
2019-01-18 04:19:49 +08:00
# Use golang string interoplation in config files
To enable set `ops_render_config` to `true`. Both `${ENV_VAR}` and `$ENV_VAR` are supported.
## Example Command
```sh
ops_render_config=true ops run -p <port> -c <file> <app>
# or
export ops_render_config=true
ops run -p <port> -c <file> <app>
```
## Example config
```JSON
{
"Args":[
"--user",
"${USER}",
"--password",
"$PASSWORD"
],
"Dirs":["myapp/static"]
}
```
2018-10-11 02:15:41 +08:00
# Example config file
2019-01-18 04:19:49 +08:00
OPS config files are plain JSON, below is an example.
2019-01-18 04:19:49 +08:00
2019-06-26 06:58:46 +08:00
```JSON
{
"Args":["one","two"],
"Dirs":["myapp/static"]
}
2019-06-26 06:58:46 +08:00
```
## Setup networking
New users wishing to play around in a dev environment are encouraged to
use the default user-mode networking. Other production users are
encouraged to utilize native cloud builds such as [Google
Cloud](https://nanovms.gitbook.io/ops/google_cloud) which
handle networking for you.
Only advanced/power users should use the bridge networking option.
2019-02-21 05:13:20 +08:00
## Useful Ops Environment Variables
The following environment variables are available to you
* `ops_render_config` - Set to `true` to use Golang ENV var interpolation to render your JSON configs.
2019-02-21 05:13:20 +08:00
## Reporting Bugs
Feel free to open up a pull request. It's helpful to have your OPS
version and the release channel you are using.
Also, if it doesn't work on the main release, then you can try the nightly.
The main release can tail the nightly by many weeks sometimes.
2019-05-17 03:12:07 +08:00
```sh
2019-02-21 05:13:20 +08:00
ops version
```
If you are using a package, get the package hash:
2019-02-21 05:13:20 +08:00
```sh
jq '."gnatsd_1.4.1"' ~/.ops/packages/manifest.json
2019-02-21 05:13:20 +08:00
```
## Pull Requests
If you have an idea for a new feature and it might take longer than a
few hours or days to complete, then it's worth opening a feature request ticket to
2019-02-21 05:13:20 +08:00
ideate it first before jumping into code. There might be someone already
working on the feature or plans to do something entirely different.
## Security
2019-04-25 05:50:26 +08:00
[Security](https://github.com/nanovms/ops/blob/master/SECURITY.md)
Feel free to email security[at]nanovms[dot]com.
2019-05-17 03:12:07 +08:00
# Support
2019-05-17 03:12:07 +08:00
If you are having trouble running a particular application please feel
free to open an issue and we can take a look. In general we'll only want
to support the latest release from a given application/project, however,
2019-05-17 03:12:07 +08:00
if you really want/need support for something older there are paid
support plans available - contact the folks at https://nanovms.com.