diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..24c7c6f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git/ +target/ +temp/ +.env diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml new file mode 100644 index 0000000..aac3dc6 --- /dev/null +++ b/.github/workflows/fly.yml @@ -0,0 +1,19 @@ +# https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ +name: Fly Deploy + +on: + push: + branches: + - master + +jobs: + deploy: + name: Deploy app + runs-on: ubuntu-latest + concurrency: deploy-group # 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 --image-label $(git rev-parse HEAD) + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index cb194f0..c5b3f3c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -18,6 +18,30 @@ git push heroku ``` +## fly.io configuration +* First time +```sh +yay -S flyctl-bin +fly secrets set KEY=VALUE +fly launch +``` + +* Deploy from local +```sh +fly deploy --image-label $(git rev-parse HEAD) +``` + +* Deploy from github + https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ + See .github/workflows/fly.yml + `FLY_API_TOKEN` - get using `fly tokens create deploy -x 999999h` + +* Get git commit hash for current release +```sh +fly image show # column TAG +``` + + ## Needed environment variables From https://github.com/settings/apps/factorio-mods-localization-helper: * `GITHUB_APP_ID` - App ID diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8eddbda --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM rust AS builder +COPY . . +RUN cargo build --release + +FROM archlinux +COPY --from=builder ./target/release/fml ./target/release/fml +COPY --from=builder Rocket.toml Rocket.toml +ENV RUST_BACKTRACE 1 +CMD ["/target/release/fml"] diff --git a/Rocket.toml b/Rocket.toml index 54a3fad..e200c55 100644 --- a/Rocket.toml +++ b/Rocket.toml @@ -1,3 +1,4 @@ [release] address = "0.0.0.0" cli_colors = false +port = 8080 diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..76246f3 --- /dev/null +++ b/fly.toml @@ -0,0 +1,21 @@ +# fly.toml app configuration file generated for factorio-mods-localization on 2024-03-25T23:19:01+03:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "factorio-mods-localization" +primary_region = "waw" + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = false + auto_start_machines = true + min_machines_running = 1 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 512 + swap_size_mb = 512