Skip to content
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
53 changes: 31 additions & 22 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
name: Docker
name: Build and publish on Docker Hub

on:
push:
# Publish `master` as Docker `edge` image.
# Publish master as Docker 'edge' image
branches:
- master

# Publish `v1.2.3` tags as same tag and latest release as 'latest'
# Publish 'v1.2.3' tags as same tag and latest release as 'latest'
tags:
- v*

jobs:
push_to_registry:
name: Push Docker image to Docker Hub

build_and_publish:
name: Build and publish on Docker Hub
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Get tag name
id: get_tag_name
run: echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}

- name: Publish master as 'edge'
if: contains(github.ref, 'master')
uses: docker/build-push-action@v1
uses: actions/checkout@v6

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and publish master as 'edge'
if: github.ref_name == 'master'
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
repository: wirepas/${{ github.event.repository.name }}
tags: edge

- name: Publish tagged version as 'version' and 'latest'
if: "!contains(github.ref, 'master')"
uses: docker/build-push-action@v1
push: true

- name: Build and publish tagged version as 'version' and 'latest'
if: github.ref_type == 'tag'
uses: docker/build-push-action@v6
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
context: .
platforms: linux/amd64,linux/arm64
repository: wirepas/${{ github.event.repository.name }}
tags: latest,${{ steps.get_tag_name.outputs.TAG_NAME }}
tags: latest,${{ github.ref_name }}
push: true
41 changes: 41 additions & 0 deletions .github/workflows/manual-docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Manually build and publish on Docker Hub

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish on Docker Hub'
required: true
type: string

jobs:
build_and_publish:
name: Manually build and publish on Docker Hub
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and publish the selected tag
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
repository: wirepas/${{ github.event.repository.name }}
tags: ${{ inputs.tag }}
push: true
30 changes: 0 additions & 30 deletions .github/workflows/manual_push_docker.yml

This file was deleted.

51 changes: 36 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
FROM ubuntu:24.04
# Use the 24.04 LTS release instead of latest to have stable environement
# Ubuntu 24.04 LTS release instead of latest to ensure a stable environment
FROM ubuntu:24.04 AS base-all

# Use the specified target architecture, or the host architecture if not set
ARG TARGETARCH

# AMD64 build parameters
FROM base-all AS build-amd64
ARG BUILD_ARCH="x86_64"

# ARM64 build parameters
FROM base-all AS build-arm64
ARG BUILD_ARCH="aarch64"

FROM build-${TARGETARCH} AS final

# Remove ubuntu user to free uid=1000 and gid=1000
RUN touch /var/mail/ubuntu && chown ubuntu /var/mail/ubuntu && userdel -r ubuntu
Expand All @@ -8,33 +21,41 @@ RUN touch /var/mail/ubuntu && chown ubuntu /var/mail/ubuntu && userdel -r ubuntu
ARG user=wirepas
RUN useradd -ms /bin/bash ${user}

# Install python3, pip and wget
# Install packages for software development: python3, git, doxygen, ...
RUN apt-get update \
&& apt-get install -y \
curl \
doxygen \
git \
python3 \
python3-pip \
xz-utils \
&& rm -fr /var/libapt/lists/*

# Install pycryptodome package (Crypto module)
# needed for scratchpad image generation.
# Note! Ubuntu python3-pycryptodome system package
# is based on pycryptodomex (Cryptodome module),
# not to pycryptodome (Crypto module), thus
# it cannot be used instead.
# Install Python packages
#
# The pycryptodome package is needed for scratchpad image generation.
#
# NOTE: The Ubuntu python3-pycryptodome system package is based on the
# pycryptodomex Python package, which uses the "Cryptodome" Python namespace.
# Wirepas SDK utilities use the "Crypto" Python namespace, so the Ubuntu package
# cannot be used.
RUN pip3 install --break-system-packages pycryptodome==3.20.0

WORKDIR /home/${user}

# Install Arm compiler
RUN curl -Lso arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz?rev=7bd049b7a3034e64885fa1a71c12f91d&hash=732D909FA8F68C0E1D0D17D08E057619" \
&& tar -xf arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz -C /opt/ \
&& rm -f arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz
# Download and install the correct ARM toolchain based on target architecture
ARG ARM_TOOLCHAIN_NAME_NO_ARCH="arm-gnu-toolchain-12.2.rel1-arm-none-eabi"
ARG ARM_TOOLCHAIN_NAME="arm-gnu-toolchain-12.2.rel1-${BUILD_ARCH}-arm-none-eabi"
ARG ARM_TOOLCHAIN_URL="https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/${ARM_TOOLCHAIN_NAME}.tar.xz"

RUN curl -Lso arm-gnu-toolchain.tar.xz "${ARM_TOOLCHAIN_URL}" \
&& tar -xf arm-gnu-toolchain.tar.xz -C /opt/ \
&& rm -f arm-gnu-toolchain.tar.xz \
&& ln -s "${ARM_TOOLCHAIN_NAME}" "/opt/${ARM_TOOLCHAIN_NAME_NO_ARCH}"

# Add Gcc 12.2.rel1 compiler to default path
ENV PATH="/opt/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin:${PATH}"
# Add ARM toolchain to default path
ENV PATH="/opt/${ARM_TOOLCHAIN_NAME_NO_ARCH}/bin:${PATH}"

# No need to be root anymore
USER ${user}
Expand Down