feat: deploy to flyio

This commit is contained in:
Tine 2024-02-11 10:15:00 +01:00
parent e45fc81faa
commit c1fbd561bb
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw
7 changed files with 76 additions and 3 deletions

14
.github/workflows/deploy.yaml vendored Normal file
View file

@ -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/setup-flyctl@v1.5
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

View file

@ -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/). - [ ] Some nice UI to try out [htmx](https://htmx.org/).
![Screenshot](docs/screenshot.png) ![Screenshot](docs/screenshot.png)
Demo is available at https://zdravko.fly.io.
# Development # Development

View file

@ -3,6 +3,7 @@ package main
import ( import (
"log" "log"
"net/http" "net/http"
"os"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -11,6 +12,11 @@ import (
) )
func main() { func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
r := mux.NewRouter() r := mux.NewRouter()
// Server static files // Server static files
@ -19,6 +25,6 @@ func main() {
r.HandleFunc("/", pages.Index).Methods("GET") r.HandleFunc("/", pages.Index).Methods("GET")
r.HandleFunc("/settings", pages.Settings).Methods("GET") r.HandleFunc("/settings", pages.Settings).Methods("GET")
log.Println("Server started on :8000") log.Println("Server started on", port)
log.Fatal(http.ListenAndServe(":8000", r)) log.Fatal(http.ListenAndServe(":"+port, r))
} }

View file

@ -3,6 +3,7 @@
"go@1.21", "go@1.21",
"temporal-cli@latest", "temporal-cli@latest",
"watchexec@latest", "watchexec@latest",
"tailwindcss@latest" "tailwindcss@latest",
"flyctl@latest"
] ]
} }

View file

@ -1,6 +1,26 @@
{ {
"lockfile_version": "1", "lockfile_version": "1",
"packages": { "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"
}
}
},
"go@1.21": { "go@1.21": {
"last_modified": "2024-01-27T14:55:31Z", "last_modified": "2024-01-27T14:55:31Z",
"resolved": "github:NixOS/nixpkgs/160b762eda6d139ac10ae081f8f78d640dd523eb#go", "resolved": "github:NixOS/nixpkgs/160b762eda6d139ac10ae081f8f78d640dd523eb#go",

27
fly.toml Normal file
View file

@ -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

View file

@ -38,3 +38,7 @@ run-worker:
# Run full development environment # Run full development environment
run: run:
devbox services up devbox services up
# Deploy the application to fly.io
deploy:
fly deploy