Skip to content

Commit

Permalink
Maybe it is the scope?
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotwutingfeng committed Jul 9, 2023
1 parent 88e5d22 commit 50738ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
run: earthly --version

- name: Run build
run: earthly --ci --push +docker
run: earthly --ci --push +docker --repo ghcr.io/elliotwutingfeng/tokei_rs
18 changes: 12 additions & 6 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@ FROM rust:latest
WORKDIR /tokei_rs

install-chef:
ARG repo
RUN cargo install cargo-chef
SAVE IMAGE --push ghcr.io/elliotwutingfeng/tokei_rs/cache/install-chef
SAVE IMAGE --push $repo/cache/install-chef

prepare:
ARG repo
FROM +install-chef
COPY --dir . .
RUN cargo chef prepare --recipe-path recipe.json
SAVE ARTIFACT recipe.json
SAVE IMAGE --push ghcr.io/elliotwutingfeng/tokei_rs/cache/prepare
SAVE IMAGE --push $repo/cache/prepare

build-deps:
ARG repo
FROM +install-chef
COPY +prepare/recipe.json ./

# build dependencies as separate layer to be cached
RUN cargo chef cook --release --recipe-path recipe.json

SAVE IMAGE --push ghcr.io/elliotwutingfeng/tokei_rs/cache/deps
SAVE IMAGE --push $repo/cache/deps

build:
ARG repo
FROM +build-deps

# copy project
Expand All @@ -32,22 +36,24 @@ build:
RUN cargo build --release

SAVE ARTIFACT target/release/tokei_rs tokei_rs
SAVE IMAGE --push ghcr.io/elliotwutingfeng/tokei_rs/cache/build
SAVE IMAGE --push $repo/cache/build

docker:
ARG repo
FROM ubuntu:jammy
EXPOSE 8000
COPY +build/tokei_rs tokei_rs
RUN apt-get update && apt-get upgrade -y && apt-get install -y git
ENTRYPOINT ["./tokei_rs"]
SAVE IMAGE --push ghcr.io/elliotwutingfeng/tokei_rs
SAVE IMAGE --push $repo

compose:
ARG repo
FROM earthly/dind:alpine
WORKDIR /test
COPY compose.yml ./
WITH DOCKER \
--compose compose.yml \
--load ghcr.io/elliotwutingfeng/tokei_rs:latest(+docker)
--load $repo:latest(+docker)
RUN docker compose down && docker compose up --remove-orphans
END

0 comments on commit 50738ec

Please sign in to comment.