Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Threated committed Apr 4, 2024
1 parent 264b82c commit 2b9de84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
26 changes: 7 additions & 19 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,14 @@ jobs:
docker:
# This workflow defines how a maven package is built, tested and published.
# Visit: https://github.com/samply/github-workflows/blob/develop/.github/workflows/docker-ci.yml, for more information
uses: samply/github-workflows/.github/workflows/docker-ci.yml@main
uses: samply/github-workflows/.github/workflows/rust.yml@main
with:
# The Docker Hub Repository you want eventually push to, e.g samply/share-client
image-name: "samply/rustyspot"
# image-tag-suffix: ${{ matrix.features && format('-{0}', matrix.features) }}
# Define special prefixes for docker tags. They will prefix each images tag.
# image-tag-prefix: "foo"
# Define the build context of your image, typically default '.' will be enough
# build-context: '.'
# Define the Dockerfile of your image, typically default './Dockerfile' will be enough
build-file: './Dockerfile'
# NOTE: This doesn't work currently
# A list of build arguments, passed to the docker build
# build-args: |
# FEATURE=-${{ matrix.features }}
# Define the target platforms of the docker build (default "linux/amd64,linux/arm64/v8")
# build-platforms: "linux/amd64"
# If your actions generate an artifact in a previous build step, you can tell this workflow to download it
# artifact-name: '*'
push-to: dockerhub
# For information on these variables, please refer to https://github.com/samply/github-workflows/tree/main/.github/workflows/rust.yml
# Docker Hub name will be {image-prefix}{component}
image-prefix: "samply/"
components: '[ "rustyspot" ]'
#architectures: '[ "amd64" ]'
push-to: ${{ (github.ref_protected == true || github.event_name == 'workflow_dispatch') && 'dockerhub' || 'ghcr' }}
# This passes the secrets from calling workflow to the called workflow
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "spot"
name = "rustyspot"
version = "0.2.0"
edition = "2021"
license = "Apache-2.0"
Expand Down
27 changes: 10 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
FROM lukemathwalker/cargo-chef:latest-rust-bookworm AS chef
WORKDIR /app
FROM alpine AS chmodder
ARG FEATURE
ARG TARGETARCH
ARG COMPONENT
COPY /artifacts/binaries-$TARGETARCH$FEATURE/$COMPONENT /app/$COMPONENT
RUN chmod +x /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 spot

FROM gcr.io/distroless/cc-debian12 AS runtime
COPY --from=builder /app/target/release/spot /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/spot"]
FROM gcr.io/distroless/cc-debian12
ARG COMPONENT
COPY --from=chmodder /app/$COMPONENT /usr/local/bin/spot
ENTRYPOINT [ "/usr/local/bin/spot" ]

0 comments on commit 2b9de84

Please sign in to comment.