Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Modernize CI #2487

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: Build Docker container on push

on:
push:
branches:
- "*"
push:
branches:
- "*"

jobs:
build:
name: Build image
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout project
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set env variables
run: |
Expand All @@ -21,23 +26,25 @@ jobs:
echo "IMAGE_NAME=${REPO_OWNER,,}/${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Setup Docker buildx action
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
id: buildx

- name: Run Docker buildx
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/$IMAGE_NAME:$BRANCH \
--output "type=registry" ./
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/$IMAGE_NAME:$BRANCH \
--cache-from type=gha \
--cache-to type=gha,mode=max \
--output "type=registry" ./
20 changes: 11 additions & 9 deletions .github/workflows/docker-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ on:
jobs:
build:
name: Build image
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

steps:
- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set env variables
run: |
Expand All @@ -22,21 +22,23 @@ jobs:
echo "IMAGE_NAME=${REPO_OWNER,,}/${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Setup Docker buildx action
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Run Docker buildx
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/$IMAGE_NAME:$TAG \
--output "type=registry" ./
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/$IMAGE_NAME:$TAG \
--cache-from type=gha \
--cache-to type=gha,mode=max \
Comment on lines +42 to +43
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables caching.

--output "type=registry" ./
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@
ARG USER=specter
ARG DIR=/data/

FROM python:3.10-slim-bullseye AS builder
FROM python:3.10-bookworm AS builder

ARG VERSION
ARG REPO

RUN apt update && apt install -y git build-essential libusb-1.0-0-dev libudev-dev libffi-dev libssl-dev rustc cargo libpq-dev
RUN apt update && apt install -y git libusb-1.0-0-dev libudev-dev libffi-dev libssl-dev rustc cargo libpq-dev
Comment on lines -12 to +17
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also just a build speed optimization, instead of using the slim image, just use the non-slim image during build, which has most packages we need for building preinstalled.


WORKDIR /

WORKDIR /specter-desktop

COPY . .
COPY requirements.txt .

RUN pip3 install --upgrade pip
RUN pip3 install babel cryptography
RUN pip3 install .
RUN pip3 install -r requirements.txt

COPY . .

RUN pip3 install . --no-deps
Comment on lines -23 to +31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main part of this fix, which is a change in the order deps are installed.

It also makes builds faster as a side effect.



FROM python:3.10-slim-bullseye as final
FROM python:3.10-slim-bookworm as final

ARG USER
ARG DIR
Expand Down
Loading