ci: speed up build with crystal arm64 binary

This commit is contained in:
sjdonado
2025-02-07 19:18:11 +01:00
parent 66fd6db3c2
commit 30fb539289
2 changed files with 29 additions and 19 deletions
+4 -3
View File
@@ -22,9 +22,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
@@ -42,12 +39,16 @@ jobs:
- name: Build and push platform image
uses: docker/build-push-action@v5
env:
CRYSTAL_WORKERS: ${{ matrix.platform == 'linux/amd64' && 4 || 2 }}
with:
context: .
platforms: ${{ matrix.platform }}
push: true
tags: |
sjdonado/bit:${{ github.event_name == 'release' && steps.version.outputs.version || 'latest' }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
build-args: |
TARGETARCH=${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
cache-from: type=gha
cache-to: type=gha,mode=max
+25 -16
View File
@@ -1,32 +1,41 @@
FROM alpine:edge AS build
FROM debian:bookworm-slim AS build
ARG TARGETARCH
ENV ENV=production
WORKDIR /usr/src/app
RUN apk update && apk add --no-cache \
RUN apt-get update && apt-get install -y \
curl \
gnupg \
ca-certificates \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://packagecloud.io/84codes/crystal/gpgkey | gpg --dearmor > /etc/apt/trusted.gpg.d/84codes_crystal.gpg \
&& echo "deb [signed-by=/etc/apt/trusted.gpg.d/84codes_crystal.gpg] https://packagecloud.io/84codes/crystal/debian/ bookworm main" > /etc/apt/sources.list.d/84codes_crystal.list
RUN apt-get update && apt-get install -y \
crystal \
shards \
yaml-dev \
sqlite-dev \
openssl-dev
libssl-dev \
libyaml-dev \
libsqlite3-dev \
libevent-dev \
&& rm -rf /var/lib/apt/lists/*
COPY . .
RUN shards install
RUN shards build --release --no-debug
RUN shards install --production
RUN shards build --release --no-debug --progress --stats
FROM alpine:edge AS runtime
FROM debian:bookworm-slim AS runtime
ENV ENV=production
WORKDIR /usr/src/app
RUN apk add --no-cache \
gc \
pcre2 \
libevent \
yaml \
sqlite-libs \
openssl
RUN apt-get update && apt-get install -y \
libssl3 \
libyaml-0-2 \
libsqlite3-0 \
libevent-2.1-7 \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p sqlite