-
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.
add docker-compose file add workflow for docker ghcr.io
- Loading branch information
Showing
6 changed files
with
139 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
make-cache: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Make Cache | ||
uses: Swatinem/[email protected] | ||
with: | ||
save-if: true | ||
cache-all-crates: true | ||
shared-key: tests | ||
- name: Update Toolchain | ||
run: rustup toolchain install stable --profile minimal --no-self-update | ||
- name: Job | ||
run: cargo build | ||
|
||
Clippy: | ||
needs: make-cache | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Load Cache | ||
uses: Swatinem/[email protected] | ||
with: | ||
# save-if: false | ||
shared-key: tests | ||
key: clippy | ||
- name: Update Toolchain | ||
run: rustup toolchain install stable --profile minimal --no-self-update | ||
- name: Job | ||
run: cargo clippy -- -D warnings | ||
|
||
build: | ||
needs: | ||
- Clippy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}/shuller:latest |
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,3 +1,4 @@ | ||
/target | ||
.env | ||
.DS_store | ||
Cargo.lock |
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -- Этап сборки бинарника -- | ||
FROM rust:1.80.1-alpine AS base | ||
|
||
RUN apk add --no-cache musl-dev openssl-dev | ||
|
||
ENV RUSTFLAGS="-C target-feature=-crt-static" | ||
|
||
RUN cargo install sccache | ||
RUN cargo install cargo-chef | ||
|
||
ENV RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache | ||
|
||
FROM base AS planner | ||
WORKDIR /app | ||
COPY . . | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM base AS builder | ||
WORKDIR /app | ||
# set up sccache | ||
COPY --from=planner /app/recipe.json recipe.json | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
cargo chef cook --release --recipe-path recipe.json | ||
# copy project | ||
COPY . . | ||
# build | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
cargo build --release | ||
|
||
# -- Этап итоговой сборки -- | ||
|
||
# Используем минимальный Alpine образ для конечного контейнера | ||
FROM alpine:latest | ||
|
||
# Устанавливаем рабочую директорию внутри контейнера | ||
WORKDIR /app | ||
|
||
# Устанавливаем необходимые зависимости для запуска | ||
RUN apk add --no-cache ca-certificates libgcc | ||
|
||
# Копируем собранный бинарный файл из стадии сборки | ||
COPY --from=builder /app/target/release/shuller_bot . | ||
# Указываем команду запуска | ||
CMD ["./shuller_bot"] |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: '3.8' | ||
|
||
services: | ||
shuller_bot: | ||
image: shuller_bot:latest | ||
environment: | ||
- DS_TOCKEN=YOUR_TOKEN |
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