Skip to content

Commit

Permalink
Make this deployable to Fly.io
Browse files Browse the repository at this point in the history
- add fly.toml with build release cmd
- refactor / add package scripts to accommodate prod vs dev
- update readme with more details / instructions
  • Loading branch information
floodfx committed Oct 11, 2022
1 parent 0619a11 commit ad4cc7a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 731 deletions.
2 changes: 1 addition & 1 deletion .stackblitzrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"startCommand": "npm run start"
"startCommand": "npm run dev"
}
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@

This is a simple HackerNews clone built with [LiveViewJS](https://liveviewjs.com). Inspired by (and copied from) [Ryan Caniato's](https://github.com/ryansolid) [numerous hackernews clones](https://github.com/ryansolid?tab=repositories&q=hackernews).

More info on LiveViewJS can be found on the [website](https://liveviewjs.com) and [GitHub](https://github.com/floodfx/liveviewjs).

## Auto Building in Dev
When running the `npm start dev` command (the default in Stackblitz and locally) the app will automatically rebuild when you make changes to the either the client or server code.

## Run in StackBlitz
[Run it in StackBlitz ⚡️](https://stackblitz.com/edit/liveviewjs-hackernews)
[Run in StackBlitz ⚡️](https://stackblitz.com/edit/liveviewjs-hackernews)
The default Stackblitz command is `npm start dev` which will run the app in development mode.

## Run locally
* Clone the repo and run `npm install`
* Run `npm run start` to start the server
* Run `npm run dev` to start the server
* Open `http://localhost:4002` in your browser

More info on LiveViewJS can be found on the [website](https://liveviewjs.com) and [GitHub](https://github.com/floodfx/liveviewjs).
## Run in Fly.io
There is a `fly.toml` file in the root of the project. You can deploy your own version to your own fly.io account. More info on [Fly.io](https://fly.io).

### First time fly.io Setup
* `flyctl auth login`
* `flyctl launch`

### Subsequent Deployments
* `flyctl deploy`


## Gratitude
Expand Down
45 changes: 45 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
app = "liveviewjs-hn-clone"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
builder = "heroku/buildpacks:20"
[build.args]
NODE_VERSION = "16"

[deploy]
release_command = "npm run build" # build before running

[env]
PORT = "8080"

[experimental]
allowed_public_ports = []
auto_rollback = true

[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
force_https = true
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "node-starter",
"name": "liveviewjs-hackernews",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "ts-node ./src/hn/autorun.ts",
"start": "node ./build/index.js",
"dev": "ts-node ./src/hn/autorun.ts",
"build": "npm run build:client && npm run build:server",
"build:client": "esbuild ./src/client/index.ts --bundle --outdir=public/js --platform=browser --format=esm --minify --sourcemap",
"build:server": "esbuild ./src/hn/index.ts --bundle --outdir=build --platform=node --format=cjs --minify --sourcemap",
"clean": "rm -rf build; rm -rf dist"
},
"dependencies": {
Expand Down
Loading

0 comments on commit ad4cc7a

Please sign in to comment.