Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
webNeat committed Sep 7, 2024
1 parent 33b8029 commit 11ce839
Show file tree
Hide file tree
Showing 59 changed files with 1,469 additions and 570 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
dist
.tests
hvps
lab
.aider*
55 changes: 0 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,3 @@
**This package is still under development, not ready for use yet!**

A code based opinionated way to self-host and manage web apps.

1. You write code describing what you want to deploy. For example:
```ts
import {app, deploy, host, database} from 'hosty'

// a Postgres database
const db = database({
type: 'postgres',
name: 'awesome',
user: 'myuser',
pass: 'mypass',
})

// a web app that uses the db above
const myapp = app({
domain: 'your-domain.com',
repo: 'https://github.com/....git',
branch: 'main',
env: {
DB_HOST: db.host,
DB_USER: db.user,
DB_PASS: db.pass,
DB_NAME: db.name,
}
})

// The server to which you want to deploy
const server = host({
address: 'domain name or IP'
})

// Deploy the app and database to the server
deploy(server, [db, myapp])
```
2. You run `npx hosty deploy` to apply what you described.

That's it, the database is created and your app is now deployed to `https://your-domain.com` (Yes, the SSL certificate is also taken care off!).

## Prerequisits

1. A Linux server to which you have SSH access.
- This can be a VPS, a home-lab server or any Linux machine that has a static IP.
- The user by which you connect should have the `sudo` ability.
- Only **Ubuntu** servers are supported right now.

2. [Ansible](https://www.ansible.com/) installed on your local machine.

## Get started

```
npm i hosty
```


**This package is still under development, not ready for use yet!**
20 changes: 20 additions & 0 deletions files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/srv/hosty/
services/
db-foo/
compose.yaml
...
app-foo/
.ports
local ports to use
compose.yaml
source.yaml
repo: 'repo url'
branch: 'deployed branch'
commit: 'last deployed commit hash'
Caddyfile
...
backups/
db-foo/
yyyy-mm-dd_hh-mm-ss.sql.gz
...

15 changes: 3 additions & 12 deletions src/ansible/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import { AnyTask, Host, Playbook, Role, Step } from './types.js'
import { AnyTask, Host, Playbook, Step, Tasks } from './types.js'

export * from './types.js'
export * as tasks from './tasks/index.js'
export * as roles from './roles/index.js'

export function task(data: AnyTask) {
return data
}

export function role(data: Role) {
return data
}

export function host(data: Host) {
return data
}

export function step(host: Host, role: Role): Step {
return {
hosts: host.name,
tasks: role.tasks,
handlers: role.handlers,
}
export function step(host: Host, tasks: Tasks): Step {
return { hosts: host.name, tasks }
}

export function playbook(data: Playbook) {
Expand Down
140 changes: 0 additions & 140 deletions src/ansible/roles/assert.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/ansible/roles/create_hosty_directory.ts

This file was deleted.

75 changes: 0 additions & 75 deletions src/ansible/roles/create_service.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/ansible/roles/generate_ssh_key.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/ansible/roles/index.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/ansible/roles/install_docker.ts

This file was deleted.

Loading

0 comments on commit 11ce839

Please sign in to comment.