Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kentalee committed Aug 2, 2024
1 parent bfae233 commit e8e157b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 22 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Build and Push Docker Image

on:
push:
branches:
- main # Change to your desired branch
pull_request:
branches:
- main # Change to your desired branch
workflow_dispatch:
inputs:
branch:
description: 'Target branch'
required: false
default: 'main'

jobs:
build:
runs-on: ubuntu-latest
runs-on: self-hosted

steps:
- name: Checkout repository
Expand All @@ -24,13 +24,24 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image

- name: Declare some variables
shell: bash
run: |
sha_short=$(git rev-parse --short $GITHUB_SHA)
commit_date=$(git log -1 --format=%cd --date=format:%Y%m%d)
echo "REPO_TAG=${commit_date}-${sha_short}" >> "$GITHUB_ENV"
- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
pull: true
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/picolab:latest
file: Dockerfile
tags: ${{ secrets.DOCKER_USERNAME }}/${{ vars.DOCKER_REPO }}:${{ env.REPO_TAG }}
build-args: |
APT_MIRROR=${{ vars.APT_MIRROR }}
- name: Log out from Docker Hub
run: docker logout
48 changes: 36 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
FROM ubuntu:nobel
RUN apt-get update && apt-get dist-upgrade -y && \
apt-get install -y build-essential wget curl git python3 net-tools nano cmake \
gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib \
automake autoconf texinfo libtool libftdi-dev libusb-1.0-0-d
FROM ubuntu:latest

RUN mkdir /opt/pico-sdk && cd /opt/pico-sdk && \
git clone https://github.com/raspberrypi/pico-sdk . && git submodule update --init --recursive
ARG APT_MIRROR=ports.ubuntu.com

RUN mkdir /opt/openocd && cd /opt/openocd && \
git clone https://github.com/raspberrypi/openocd --branch rp2040 . && git submodule update --init --recursive && \
./bootstrap && ./configure --enable-cmsis-dap && make -j4 && make install
ENV DEBIAN_FRONTEND=noninteractive

RUN mkdir /opt/pico-lab && cd /opt/pico-lab && \
git clone https://github.com/wuxx/pico-lab . && source ./tools/env.sh
RUN cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.backup ;\
sed -i "s@/ports.ubuntu.com/@/${APT_MIRROR}/@g" /etc/apt/sources.list.d/ubuntu.sources ;\
apt-get update && apt install ca-certificates -y ;\
sed -i 's@http://@https://@g' /etc/apt/sources.list.d/ubuntu.sources ;\
apt-get update && apt-get dist-upgrade -y ;\
apt-get install --no-install-recommends -y curl git net-tools wget nano unzip \
pkg-config cmake build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib \
automake autoconf texinfo libtool libftdi-dev libusb-1.0-0-dev libhidapi-dev ;\
mv -f /etc/apt/sources.list.d/ubuntu.sources.backup /etc/apt/sources.list.d/ubuntu.sources ;\
apt clean && apt autoclean;

RUN mkdir /opt/pico-sdk && cd /opt/pico-sdk ;\
git clone https://github.com/raspberrypi/pico-sdk --single-branch . ;\
git submodule update --init --remote --checkout --single-branch ;\
\
mkdir /opt/openocd && cd /opt/openocd ;\
git clone https://github.com/raspberrypi/openocd --single-branch --branch rp2040 . ;\
git submodule set-url tools/git2cl "https://git.savannah.nongnu.org/git/git2cl.git" ;\
git submodule update --init --remote --checkout --single-branch ;\
./bootstrap && ./configure --enable-cmsis-dap && make -j4 && make install ;\
rm -rf /opt/openocd ;\
mkdir -p /opt/openocd/src ;\
ln -s $(which openocd) /opt/openocd/src/ ;\
ln -s /usr/local/share/openocd/scripts /opt/openocd/tcl ;\
echo "adapter speed 5000" >> /opt/openocd/tcl/target/rp2040.cfg ;\
echo "export OPENOCD_ROOT=/opt/openocd" >> /etc/profile.d/02-openocd.sh ;\
\
mkdir /opt/pico-lab && cd /opt/pico-lab ;\
git clone https://github.com/wuxx/pico-lab --single-branch . ;\
git submodule update --init --remote --checkout --single-branch ;\
echo "export export PATH=\${PATH}:\${pico-lab}/tools" >> /etc/profile.d/03-pico-lab.sh ;\
\
find /opt -name ".git" -type d -exec rm -rf {} + ;

0 comments on commit e8e157b

Please sign in to comment.