-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e944988
commit 152befe
Showing
5 changed files
with
50 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,30 @@ | ||
name: Docker Hub Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: pulling git repo | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: ${{ runner.os }}-cargo- | ||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
- name: Build and test code | ||
run: | | ||
cargo build --verbose | ||
cargo test --verbose | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
push: true | ||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/skylark:build-v1.001 | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
build-args: | | ||
RUST_BACKTRACE=1 | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} | ||
tags: ${{ secrets.DOCKER_USERNAME }}/spotify:latest |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "logging" | ||
name = "spotify" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
FROM messense/rust-musl-cross:x86_64-musl as chef | ||
RUN cargo install cargo-chef | ||
WORKDIR /logging | ||
# Use the official Rust image as the base image | ||
FROM rust:latest AS builder | ||
|
||
FROM chef AS planner | ||
# Copy source code from previous stage | ||
COPY . . | ||
# Generate info for caching dependencies | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
# Create a new empty shell project | ||
RUN USER=root cargo new --bin spotify | ||
WORKDIR /spotify | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /logging/recipe.json recipe.json | ||
# Enable backtrace for better error logs | ||
ENV RUST_BACKTRACE=1 | ||
# Build & cache dependencies | ||
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json | ||
# Copy source code from previous stage | ||
COPY . . | ||
# Build application | ||
RUN cargo build --release --target x86_64-unknown-linux-musl | ||
# Copy the Cargo.toml and Cargo.lock files | ||
COPY Cargo.toml Cargo.lock ./ | ||
|
||
# Create a new stage with a minimal image | ||
FROM scratch | ||
COPY --from=builder /logging/target/x86_64-unknown-linux-musl/release/logging /logging | ||
ENTRYPOINT ["/logging"] | ||
EXPOSE 7860 | ||
# Copy the source code | ||
COPY src ./src | ||
|
||
# Build the application in release mode | ||
RUN cargo build --release | ||
|
||
# Use the official Debian image as the base image for the runtime | ||
FROM debian:buster-slim | ||
|
||
# Copy the compiled binary from the builder stage | ||
COPY --from=builder /spotify/target/release/spotify /usr/local/bin/spotify | ||
|
||
# Run the application | ||
CMD ["spotify"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use logging::run; | ||
use spotify::run; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
|