Skip to content

Commit

Permalink
deployed to fly.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Tguntenaar committed Nov 6, 2024
1 parent ac051fb commit ee0ba0f
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 20 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 47 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,55 @@
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
# --- Cargo Chef Stage (for caching dependencies) ---
FROM rust:1.78.0-bookworm as chef
WORKDIR /app

FROM chef AS planner
RUN cargo install cargo-chef
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!
# --- Dependency Caching Stage ---
FROM chef as cache
WORKDIR /app

RUN apt-get update -y && apt-get install -y \
libssl-dev \
ca-certificates \
libudev-dev \
libusb-1.0-0-dev \
pkg-config \
libudev-dev \
build-essential

COPY --from=chef /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Build application

# --- Application Build Stage ---
FROM cache as builder
WORKDIR /app
RUN apt-get update -y && apt-get install -y \
libssl-dev \
ca-certificates \
libudev-dev \
libusb-1.0-0-dev \
pkg-config \
libudev-dev \
build-essential
COPY . .
RUN cargo build --release --bin devhub-cache-api
COPY --from=cache /app/target target
ENV SQLX_OFFLINE=true
RUN cargo build --release

# We do not need the Rust toolchain to run the binary!
FROM debian:bookworm-slim AS runtime
# --- Final Stage with Minimal Base Image ---
FROM debian:bookworm-slim
RUN apt-get update -y && apt-get install -y \
libssl-dev \
ca-certificates \
libudev-dev \
libusb-1.0-0-dev \
pkg-config \
libudev-dev \
build-essential
RUN useradd -ms /bin/bash app
USER app
WORKDIR /app
COPY --from=builder /app/target/release/devhub-cache-api /usr/local/bin
ENTRYPOINT ["/usr/local/bin/devhub-cache-api"]
COPY --from=builder /app/target/release/devhub-cache-api .
EXPOSE 8000
CMD ["./devhub-cache-api"]
11 changes: 3 additions & 8 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# fly.toml app configuration file generated for devhub-cache-api-rs on 2024-10-29T10:00:35-05:00
# fly.toml app configuration file generated for devhub-cache-api-rs on 2024-11-06T08:54:33+07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'devhub-cache-api-rs'
primary_region = 'dfw'
primary_region = 'ams'

[build]

[env]
PORT = '8080'
ROCKET_ADDRESS = '0.0.0.0'
ROCKET_PORT = '8080'

[http_service]
internal_port = 8080
internal_port = 8000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
Expand Down

0 comments on commit ee0ba0f

Please sign in to comment.