Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
TOwInOK committed Oct 26, 2024
1 parent c1d70af commit 6dd7bbe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug

- name: Login to Container Registry
uses: docker/login-action@v3
Expand All @@ -59,6 +61,15 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Restore cache
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
Expand All @@ -81,8 +92,21 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: |
type=local,src=/tmp/.buildx-cache
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: |
type=local,dest=/tmp/.buildx-cache-new,mode=max
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
outputs: |
type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Временный фикс для кэша
- name: Move cache
if: always()
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Check image
if: success()
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ WORKDIR /app
COPY --from=planner /app/recipe.json recipe.json
# Собираем только зависимости
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
cargo chef cook --release --recipe-path recipe.json

# Третий этап - Финальная сборка
Expand All @@ -38,9 +39,10 @@ COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo/registry /usr/local/cargo/registry
# Копируем исходный код
COPY . .
# Собираем только наш код
# Собираем наш код
RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo build --release --offline
--mount=type=cache,target=/usr/local/cargo/git \
cargo build --release

# Финальный образ
FROM alpine:latest
Expand Down

0 comments on commit 6dd7bbe

Please sign in to comment.