From ead10c1bd6048c56af4d4caf1790cd60c0fbfe44 Mon Sep 17 00:00:00 2001 From: nhnghia Date: Tue, 5 Mar 2024 15:50:24 +0100 Subject: [PATCH] init code --- .github/workflows/build-docker-container.yml | 38 ++++++++++++++++++++ .gitignore | 1 + Dockerfile | 21 +++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .github/workflows/build-docker-container.yml create mode 100644 .gitignore create mode 100644 Dockerfile diff --git a/.github/workflows/build-docker-container.yml b/.github/workflows/build-docker-container.yml new file mode 100644 index 0000000..2fc6b2a --- /dev/null +++ b/.github/workflows/build-docker-container.yml @@ -0,0 +1,38 @@ +name: C/C++ CI + +on: + push: + tags: ["v*"] # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Initialize variables + env: + GITHUB_REF: ${{ github.ref }} + run: | + cat <> $GITHUB_ENV + PACKAGE_VERSION=$(echo $GITHUB_REF | tr -d 'refs/tags/' ) + EOF + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker images + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ghcr.io/montimage/linuxptp:${{ env.PACKAGE_VERSION }} + ghcr.io/montimage/linuxptp:latest + build-args: | + LINUXPTP_VERSION=${{ env.PACKAGE_VERSION }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8fe4fa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.project diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dc7fc0f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +ARG LINUXPTP_VERSION=v4.1 +FROM ubuntu:22.04 AS builder + +RUN apt update && apt install -y git make gcc musl-dev + +WORKDIR /linuxptp-agent +RUN git clone https://git.code.sf.net/p/linuxptp/code linuxptp && \ + cd linuxptp && \ + git checkout ${LINUXPTP_VERSION} && \ + make + +FROM ubuntu:22.04 + +COPY --from=builder /linuxptp-agent/linuxptp/ptp4l /usr/local/bin/ +COPY --from=builder /linuxptp-agent/linuxptp/phc2sys /usr/local/bin/ +COPY --from=builder /linuxptp-agent/linuxptp/pmc /usr/local/bin/ + +RUN apt update && apt install -y musl-dev bc && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* && \ + ldconfig \ No newline at end of file