Skip to content

Commit

Permalink
feat: deploy to flyio
Browse files Browse the repository at this point in the history
  • Loading branch information
mentos1386 committed Feb 11, 2024
1 parent e45fc81 commit c1fbd56
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Deploy
on: [push]
branch: main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: superfly/flyctl-actions/[email protected]
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Mostly just a project to test [temporal.io](https://temporal.io/).
- [ ] Some nice UI to try out [htmx](https://htmx.org/).

![Screenshot](docs/screenshot.png)
Demo is available at https://zdravko.fly.io.

# Development

Expand Down
10 changes: 8 additions & 2 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"log"
"net/http"
"os"

"github.com/gorilla/mux"

Expand All @@ -11,6 +12,11 @@ import (
)

func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}

r := mux.NewRouter()

// Server static files
Expand All @@ -19,6 +25,6 @@ func main() {
r.HandleFunc("/", pages.Index).Methods("GET")
r.HandleFunc("/settings", pages.Settings).Methods("GET")

log.Println("Server started on :8000")
log.Fatal(http.ListenAndServe(":8000", r))
log.Println("Server started on", port)
log.Fatal(http.ListenAndServe(":"+port, r))
}
3 changes: 2 additions & 1 deletion devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"[email protected]",
"temporal-cli@latest",
"watchexec@latest",
"tailwindcss@latest"
"tailwindcss@latest",
"flyctl@latest"
]
}
20 changes: 20 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
{
"lockfile_version": "1",
"packages": {
"flyctl@latest": {
"last_modified": "2024-02-05T02:15:44Z",
"resolved": "github:NixOS/nixpkgs/0a254180b4cad6be45aa46dce896bdb8db5d2930#flyctl",
"source": "devbox-search",
"version": "0.1.147",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/r2nqhmbcmijhcc1saz41hcxz8rr4b41x-flyctl-0.1.147"
},
"aarch64-linux": {
"store_path": "/nix/store/04xazp0avkk26zyf50prl1mskflfpb86-flyctl-0.1.147"
},
"x86_64-darwin": {
"store_path": "/nix/store/4zbndlj7m4wy834qppl2rir9fcwrzji4-flyctl-0.1.147"
},
"x86_64-linux": {
"store_path": "/nix/store/8cfzmq9dka6vaah9j2lpdpbkpm4q0i4m-flyctl-0.1.147"
}
}
},
"[email protected]": {
"last_modified": "2024-01-27T14:55:31Z",
"resolved": "github:NixOS/nixpkgs/160b762eda6d139ac10ae081f8f78d640dd523eb#go",
Expand Down
27 changes: 27 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.

app = 'zdravko'
primary_region = 'waw'

[build]
builder = 'paketobuildpacks/builder:base'
buildpacks = ['gcr.io/paketo-buildpacks/go']

[env]
PORT = '8080'

[processes]
server = "server"
#worker = "worker"

[http_service]
processes = ["server"]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true

[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 256
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ run-worker:
# Run full development environment
run:
devbox services up

# Deploy the application to fly.io
deploy:
fly deploy

0 comments on commit c1fbd56

Please sign in to comment.