Skip to content

Commit

Permalink
ci: add dockerfile and workflow action for releasing image
Browse files Browse the repository at this point in the history
Dockerfile and Github action which builds and releases Docker image.
Docker image will have Nordic toolchain bundle inside it.

Signed-off-by: Kari Hamalainen <[email protected]>
  • Loading branch information
karhama authored and thst-nordic committed Oct 31, 2023
1 parent a23a23a commit 39a730c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and Push Docker Image

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

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

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

- name: Build and push Docker image
run: |
TOOLCHAIN_ID=$(../print_toolchain_checksum.sh)
docker build -t ghcr.io/${{ github.repository }}-toolchain:${{ github.ref_name }} --build-arg VERSION=$TOOLCHAIN_ID .
docker push ghcr.io/${{ github.repository }}-toolchain:${{ github.ref_name }}
working-directory: scripts/docker
30 changes: 30 additions & 0 deletions scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ubuntu:22.04 as nrfutil-builder

ARG VERSION
RUN apt-get update && apt-get install -y \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil && chmod +x nrfutil \
&& ./nrfutil install toolchain-manager && ./nrfutil toolchain-manager install --toolchain-bundle-id $VERSION
RUN ./nrfutil toolchain-manager env --as-script > /root/toolchain-env.sh


FROM ubuntu:22.04

# Link to repo (https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#labelling-container-images)
LABEL org.opencontainers.image.source=https://github.com/nrfconnect/sdk-nrf
# Set metadata for an image
LABEL org.opencontainers.image.description="This image contains toolchain for sdk-nrf."

RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Copy toolchain
COPY --from=nrfutil-builder /root/ncs/toolchains /root/ncs/toolchains
COPY --from=nrfutil-builder /root/toolchain-env.sh /root/toolchain-env.sh

# Add entrypoint which calls toolchain-env.sh
ADD entrypoint.sh /root/entrypoint.sh
ENTRYPOINT ["/root/entrypoint.sh"]
CMD ["bin/bash"]
4 changes: 4 additions & 0 deletions scripts/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

source /root/toolchain-env.sh
exec "$@"

0 comments on commit 39a730c

Please sign in to comment.