Skip to content

Commit

Permalink
GH actions for build + multiarch
Browse files Browse the repository at this point in the history
  • Loading branch information
waldner authored and db committed Oct 6, 2024
1 parent a8d6def commit 5302806
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 13 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [ "master" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:

build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Checkout repository
uses: actions/checkout@v4

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/waldner/keybase-kbfs-docker:1
cache-from: type=gha
cache-to: type=gha,mode=max

38 changes: 28 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
FROM debian:12-slim

FROM golang:1.23.2-bookworm AS builder0-arm64
ENV DEBIAN_FRONTEND=noninteractive
RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg -o /etc/apt/keyrings/yarn.asc && \
echo "deb [signed-by=/etc/apt/keyrings/yarn.asc] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn rsync fakeroot && \
git clone https://github.com/keybase/client /tmp/client && \
cd /tmp/client/packaging/linux && \
export KEYBASE_BUILD_ARM_ONLY=1 && \
./build_binaries.sh prerelease /tmp/out && \
sed -i 's|^export debian_arch=amd64|export debian_arch=arm64|' deb/package_binaries.sh && \
deb/package_binaries.sh /tmp/out && \
cp /tmp/out/deb/arm64/keybase-*-arm64.deb /tmp/keybase.deb

FROM debian:12-slim AS builder-arm64
COPY --from=builder0-arm64 /tmp/keybase.deb /tmp/keybase.deb

FROM debian:12-slim AS builder-amd64
RUN apt-get update && apt-get install -y curl && \
cd /tmp && curl -s -o /tmp/keybase.deb https://prerelease.keybase.io/keybase_amd64.deb

# stupid trick
FROM builder-${TARGETARCH} AS final-builder

FROM debian:12-slim AS final
ENV DEBIAN_FRONTEND=noninteractive
COPY --from=final-builder /tmp/keybase.deb /tmp/keybase.deb
RUN apt-get update && apt-get install -y \
perl-modules \
apt-utils \
gosu \
curl && \
curl -s -O https://prerelease.keybase.io/keybase_amd64.deb && \
apt-get install -y ./keybase_amd64.deb && \
rm keybase_amd64.deb && \
perl-modules apt-utils gosu curl \
&& apt-get install -y /tmp/keybase.deb && \
rm /tmp/keybase.deb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/cache/*

RUN useradd -m keybase

COPY entrypoint.sh /tmp
COPY run_keybase.sh /tmp
RUN chmod +x /tmp/run_keybase.sh /tmp/entrypoint.sh;
RUN chmod +x /tmp/run_keybase.sh /tmp/entrypoint.sh

ENTRYPOINT ["/tmp/entrypoint.sh"]
CMD ["/tmp/run_keybase.sh"]
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ After that, you can run `docker-compose up -d`. It uses the prebuilt image at [t
Create a file `docker-compose.override.yml` with the follwing contents:

```
version: '3'
services:
keybase:
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
keybase:
image: waldner/keybase:5
image: ghcr.io/waldner/keybase-kbfs-docker:1
container_name: keybase
restart: always

Expand Down

0 comments on commit 5302806

Please sign in to comment.