diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e34d9c7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +fly.toml +.git/ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..18e1aa0 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,13 @@ +name: Deploy to Fly.io +on: + push: + branches: [main] +jobs: + deploy: + runs-on: ubuntu-latest + 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 }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2571467 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef +WORKDIR /app + +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /app/recipe.json recipe.json +# Build dependencies - this is the caching Docker layer! +RUN cargo chef cook --release --recipe-path recipe.json +# Build application +COPY . . +RUN cargo build --release --bin zero2prod + +# We do not need the Rust toolchain to run the binary! +FROM debian:bookworm-slim AS runtime +WORKDIR /app +COPY --from=builder /app/target/release/zero2prod /usr/local/bin +ENTRYPOINT ["/usr/local/bin/zero2prod"] diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..41b6fcd --- /dev/null +++ b/fly.toml @@ -0,0 +1,25 @@ +# fly.toml app configuration file generated for app-crimson-frog-8696 on 2026-03-17T14:19:46Z +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'zero2prod-53ezmw' +primary_region = 'iad' + +[build] + +[env] + PORT = '8080' + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = 'stop' + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + cpu_kind = 'shared' + cpus = 1 + memory_mb = 256