Skip to content

Commit

Permalink
chore: ubuntu-latest runner and add docker build caching via gha
Browse files Browse the repository at this point in the history
  • Loading branch information
christianfosli committed Nov 21, 2024
1 parent 07bec45 commit f96ed27
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/review-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand All @@ -37,7 +37,11 @@ jobs:
tags="$tags -t ghcr.io/christianfosli/stellerom/review-api:latest"
fi
cd review-api
docker build $tags .
docker buildx build \
--cache-from "type=gha,scope=review-api" \
--cache-to "type=gha,mode=max,scope=review-api" \
$tags \
.
env:
DOCKER_BUILDKIT: "1"

Expand All @@ -47,7 +51,7 @@ jobs:
deploy_dev:
needs: build
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
environment: Development
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -85,7 +89,7 @@ jobs:
deploy_prod:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: deploy_dev
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
environment: Production
steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/room-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand All @@ -37,7 +37,11 @@ jobs:
tags="$tags -t ghcr.io/christianfosli/stellerom/room-api:latest"
fi
cd room-api
docker build $tags .
docker buildx build \
--cache-from "type=gha,scope=room-api" \
--cache-to "type=gha,mode=max,scope=room-api" \
$tags \
.
env:
DOCKER_BUILDKIT: "1"

Expand All @@ -47,7 +51,7 @@ jobs:
deploy_dev:
needs: build
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
environment: Development
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -83,7 +87,7 @@ jobs:
deploy_prod:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: deploy_dev
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
environment: Production
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 6 additions & 2 deletions review-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM rust:1.82 AS builder

WORKDIR /usr/src/review-api
COPY . .
RUN cargo install --path .
RUN --mount=type=bind,source=src,target=src \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,target=target/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo install --path .

FROM debian:12-slim AS final
ARG RUST_LOG=info
Expand Down
8 changes: 6 additions & 2 deletions room-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM rust:1.82 AS builder

WORKDIR /usr/src/room-api
COPY . .
RUN cargo install --path .
RUN --mount=type=bind,source=src,target=src \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,target=target/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo install --path .

FROM debian:12-slim AS final
ARG RUST_LOG=info
Expand Down

0 comments on commit f96ed27

Please sign in to comment.