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

Switch Linux CI builds to use Docker based on Ubuntu 18 #1

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Expand Up @@ -48,11 +48,8 @@ jobs:
- uses: actions/checkout@v2
- name: Build
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release
cmake --build ${{github.workspace}}/build
env:
CC: gcc-10
CXX: g++-10
./ci/linux/docker-build.sh
./ci/linux/docker-run.sh
- name: Upload Linux build
uses: actions/upload-artifact@v2
with:
Expand Down
48 changes: 48 additions & 0 deletions ci/linux/Dockerfile
@@ -0,0 +1,48 @@
# Dockerfile for building Saleae analyzers on linux
# This allows us to maintain support for older distros while building on recent distros.

# Use Ubuntu 18.04 as the base image
FROM ubuntu:18.04

# Set environment variables to avoid any interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# UID and GID are generally used to create a user with the same user and group ids as the user building this Docker image
ARG UID
ARG GID

# Ensure args are set
RUN test -n "$UID"
RUN test -n "$GID"

# Create user
RUN groupadd -g ${GID} docker
RUN useradd -m -u ${UID} -g docker docker

# Update for cmake
RUN apt-get update

# Add repository for latest cmake
RUN apt-get -y install ca-certificates gpg wget software-properties-common
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ bionic main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null

RUN apt-get -y install software-properties-common

# Add repository for GCC 10
RUN add-apt-repository ppa:ubuntu-toolchain-r/test

RUN apt-get update

RUN apt-get -y install cmake git
RUN apt-get -y install gcc-10 g++-10

# set CXX and CC so cmake uses gcc 10 as the default compiler.
ENV CXX=g++-10
ENV CC=gcc-10

RUN mkdir -p /workspace/analyzer
RUN chown docker:docker /workspace

# Set working directory
WORKDIR /workspace/analyzer
8 changes: 8 additions & 0 deletions ci/linux/build.sh
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# This is run from within the docker container to build the analyer.
mkdir build
pushd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
popd
11 changes: 11 additions & 0 deletions ci/linux/docker-build.sh
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# This script builds the docker image using the Dockerfile in this directory.

# We pass in the user and group ID, so that later when we run docker, we can ensure that all created files are owned by the current user.

# Path to THIS script
SCRIPT_PATH=`dirname $0`
SCRIPT_PATH=`readlink -e $SCRIPT_PATH`

docker build --build-arg UID=`id -u` --build-arg GID=`id -g` -t analyzer-build $SCRIPT_PATH
10 changes: 10 additions & 0 deletions ci/linux/docker-run.sh
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# This script runs the build.sh script within the docker image, mounting the current repository as a volume.

# Path to THIS script
SCRIPT_PATH=$(dirname $0)
SCRIPT_PATH=$(readlink -e $SCRIPT_PATH)
REPO_ROOT=$SCRIPT_PATH/../..

docker run --rm -v${REPO_ROOT}:/workspace/analyzer -u docker:docker analyzer-build ./ci/linux/build.sh
13 changes: 13 additions & 0 deletions ci/linux/readme.md
@@ -0,0 +1,13 @@
# Linux Analyzer CI Build

In order to maintain compatibility with older distributions of Linux, we build our release binaries using docker.

This allows us to control the glibc and libstdc++ dependencies of our binaries, and ensure that they will run on older distributions.

This is done in two steps.

First, we create a docker image. the Dockerfile and docker-build.sh configure the image with the necessary software.

Second, we run the image using docker-run.sh and build.sh.

This can be done locally, but it is not required for local development.