Skip to content

Commit

Permalink
remove arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
TOwInOK committed Oct 27, 2024
1 parent 6d94347 commit 2118af0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 126 deletions.
82 changes: 12 additions & 70 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-musl, aarch64-unknown-linux-musl
target: x86_64-unknown-linux-musl
components: rustfmt, clippy
cache: true

Expand All @@ -52,15 +52,6 @@ jobs:
docker-build:
needs: rust-checks
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- os: linux/amd64
arch: amd64
target: x86_64-unknown-linux-musl
- os: linux/arm64
arch: arm64
target: aarch64-unknown-linux-musl
env:
REGISTRY: ghcr.io

Expand All @@ -72,9 +63,6 @@ jobs:
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -93,10 +81,10 @@ jobs:
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest-${{ matrix.platform.arch }}
type=sha,format=short,suffix=-${{ matrix.platform.arch }}
type=raw,value=latest
type=sha,format=short
flavor: |
latest=false
latest=true
labels: |
org.opencontainers.image.title=shuller-bot
org.opencontainers.image.description=Anime picture fetcher bot
Expand All @@ -111,61 +99,15 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.platform.os }}
target: final-${{ matrix.platform.arch }}
platforms: linux/amd64
target: final-amd64
build-args: |
TARGETARCH=${{ matrix.platform.arch }}
RUST_TARGET=${{ matrix.platform.target }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.platform.arch }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.platform.arch }},mode=max
TARGETARCH=amd64
RUST_TARGET=x86_64-unknown-linux-musl
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max

- name: Verify push
run: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-${{ matrix.platform.arch }}
docker image inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-${{ matrix.platform.arch }}
create-manifest:
needs: docker-build
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
steps:
- name: Downcase REPO
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push manifest
run: |
# Проверяем наличие образов
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
MANIFEST_TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
echo "Creating manifest for $MANIFEST_TAG"
# Создаем и пушим манифест
docker manifest create $MANIFEST_TAG \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
docker manifest annotate $MANIFEST_TAG \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
--os linux --arch amd64
docker manifest annotate $MANIFEST_TAG \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64 \
--os linux --arch arm64
echo "Pushing manifest"
docker manifest push $MANIFEST_TAG
echo "Verifying manifest"
docker manifest inspect $MANIFEST_TAG
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker image inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
31 changes: 4 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ARG TARGETARCH
FROM alpine:latest AS base

RUN apk add --no-cache \
Expand Down Expand Up @@ -30,7 +29,7 @@ RUN mkdir src && \
cargo chef prepare --recipe-path recipe.json

# Сборка для AMD64
FROM base AS builder-amd64
FROM base AS builder
WORKDIR /app
RUN rustup target add x86_64-unknown-linux-musl
ENV RUST_TARGET=x86_64-unknown-linux-musl
Expand All @@ -40,33 +39,11 @@ RUN cargo chef cook --target ${RUST_TARGET} --recipe-path recipe.json
COPY . .
RUN cargo build --release --target ${RUST_TARGET}

# Сборка для ARM64
FROM base AS builder-arm64
WORKDIR /app
RUN rustup target add aarch64-unknown-linux-musl
ENV RUST_TARGET=aarch64-unknown-linux-musl

COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --target ${RUST_TARGET} --recipe-path recipe.json
COPY . .
RUN cargo build --release --target ${RUST_TARGET}

# Финальный образ для AMD64
FROM alpine:latest AS final-amd64
# Финальный образ
FROM alpine:latest
WORKDIR /app
RUN apk add --no-cache ca-certificates openssl
COPY --from=builder-amd64 /app/target/x86_64-unknown-linux-musl/release/shuller_bot .
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/shuller_bot .
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
CMD ["./shuller_bot"]

# Финальный образ для ARM64
FROM alpine:latest AS final-arm64
WORKDIR /app
RUN apk add --no-cache ca-certificates openssl
COPY --from=builder-arm64 /app/target/aarch64-unknown-linux-musl/release/shuller_bot .
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
CMD ["./shuller_bot"]

FROM final-${TARGETARCH}
29 changes: 0 additions & 29 deletions build.sh

This file was deleted.

0 comments on commit 2118af0

Please sign in to comment.