Repository navigation
fly.io configuration #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheJolman
wants to merge
13
commits into
main
Choose a base branch
from
devops/deploy2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fly.io configuration #194
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d62c837
attempt 1
TheJolman f8fd6ed
docker works!
TheJolman bf0da07
formatting
TheJolman a1e6ce3
volume shi
TheJolman 3f70b6b
ca-certs
TheJolman 71b973d
don't create discord session in dev mode
TheJolman a34ffe6
move env vars
TheJolman c246146
change error message
TheJolman 5d91cf2
simplify host/port config
TheJolman 6d230f3
make building less noisy
TheJolman 142b9ad
Update docs/docker.md
TheJolman 875a6d0
update comment
TheJolman 0c92526
change min_machines_running
TheJolman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # flyctl launch added from .gitignore | ||
| # If you prefer the allow list template instead of the deny list, see community template: | ||
| # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
|
|
||
| # SQLite database files | ||
| **/*.db | ||
|
|
||
| # Binaries for programs and plugins | ||
| **/bin | ||
| **/*.exe | ||
| **/*.exe~ | ||
| **/*.dll | ||
| **/*.so | ||
| **/*.dylib | ||
|
|
||
| # Test binary, built with `go test -c` | ||
| **/*.test | ||
|
|
||
| # Output of the go coverage tool, specifically when used with LiteIDE | ||
| **/*.out | ||
|
|
||
| # Dependency directories (remove the comment below to include it) | ||
| **/vendor | ||
|
|
||
| # Go workspace file | ||
| **/go.work | ||
| **/*.sqlite | ||
|
|
||
| # Nix related | ||
| **/.direnv | ||
| **/result | ||
|
|
||
| # Build artifact generated by Makefile | ||
| **/.generate.marker | ||
|
|
||
| **/tmp | ||
|
|
||
| **/.env | ||
| **/.DS_Store | ||
| fly.toml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ | ||
|
|
||
| name: Fly Deploy | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| jobs: | ||
| deploy: | ||
| name: Deploy app | ||
| runs-on: ubuntu-latest | ||
| concurrency: deploy-group # optional: ensure only one action runs at a time | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: superfly/flyctl-actions/setup-flyctl@master | ||
| - run: flyctl deploy --remote-only | ||
| env: | ||
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ARG GO_VERSION=1 | ||
| FROM golang:${GO_VERSION}-bookworm AS builder | ||
|
|
||
| WORKDIR /usr/src/app | ||
| COPY go.mod go.sum ./ | ||
| RUN go mod download && go mod verify | ||
| COPY . . | ||
| RUN go build -v -o /run-app ./cmd/acmcsuf-api | ||
|
|
||
|
|
||
| FROM debian:bookworm | ||
|
|
||
| COPY --from=builder /run-app /usr/local/bin/ | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends ca-certificates \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && mkdir -p /app/data | ||
| WORKDIR /app | ||
| COPY --from=builder /usr/src/app/sql/migrations ./sql/migrations | ||
| EXPOSE 8080 | ||
| CMD ["run-app"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Useful docker commands | ||
|
|
||
| ```sh | ||
| # build | ||
| docker build -t acmcsuf-api:latest . | ||
|
|
||
| # run | ||
| docker run --rm \ | ||
| --name acmcsuf-api \ | ||
| --mount type=volume,source=sqlite_data,target=/app/data \ | ||
| -p 8080:8080 \ | ||
| acmcsuf-api:latest | ||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # fly.toml app configuration file generated for api-acmcsuf-com-black-wind-9210 on 2026-08-01T19:15:18-07:00 | ||
| # | ||
| # See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
| # | ||
|
|
||
| app = 'api-acmcsuf-com-black-wind-9210' | ||
| primary_region = 'lax' | ||
|
|
||
| [build] | ||
| [build.args] | ||
| GO_VERSION = '1.25.0' | ||
|
|
||
| [env] | ||
| PORT = '8080' | ||
| DATABASE_URL= 'file:/app/data/acmcsuf.db?cache=shared&mode=rwc' | ||
| GIN_MODE = 'debug' | ||
| ENV = 'development' | ||
|
|
||
| [http_service] | ||
| internal_port = 8080 | ||
| force_https = true | ||
| auto_stop_machines = 'stop' | ||
| auto_start_machines = true | ||
| min_machines_running = 1 | ||
| processes = ['app'] | ||
|
|
||
| [[vm]] | ||
| memory = '256m' | ||
| cpu_kind = 'shared' | ||
| cpus = 1 | ||
|
|
||
| [mounts] | ||
| source = "sqlite_data" | ||
| destination = "/app/data" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,33 @@ package config | |
| import ( | ||
| "fmt" | ||
| "net/url" | ||
| "strings" | ||
| ) | ||
|
|
||
| // Intended to be used with .JoinPath() to construct URLs with configured host:port | ||
| // Intended to be used with .JoinPath() to construct URLs | ||
| func GetBaseURL(cfg *Config) *url.URL { | ||
| return &url.URL{ | ||
| Scheme: "http", | ||
| Host: fmt.Sprintf("%s:%s", cfg.Host, cfg.Port), | ||
| apiURL, _ := url.Parse(cfg.APIURL) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. omg trusting the Normalize func with your life 😭 . I would say potential nil pointer but the normalize func does a pretty good job at catching bad urls. |
||
| return apiURL | ||
| } | ||
|
|
||
| func NormalizeAPIURL(rawURL string) (string, error) { | ||
| apiURL, err := url.Parse(strings.TrimSpace(rawURL)) | ||
| if err != nil { | ||
| return "", fmt.Errorf("invalid API URL: %w", err) | ||
| } | ||
| if apiURL.Scheme != "http" && apiURL.Scheme != "https" { | ||
| return "", fmt.Errorf("API URL must use http or https") | ||
| } | ||
| if apiURL.Host == "" { | ||
| return "", fmt.Errorf("API URL must include a host") | ||
| } | ||
| if apiURL.User != nil || apiURL.RawQuery != "" || apiURL.Fragment != "" { | ||
| return "", fmt.Errorf("API URL must not include credentials, a query, or a fragment") | ||
| } | ||
| if apiURL.Path != "" && apiURL.Path != "/" { | ||
| return "", fmt.Errorf("API URL must not include a path") | ||
| } | ||
|
|
||
| apiURL.Path = "" | ||
| return apiURL.String(), nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.