Skip to content

Build LaserWeb Docker Image for Raspberry Pi (RPi2, RPi3, RPi4) #5

Build LaserWeb Docker Image for Raspberry Pi (RPi2, RPi3, RPi4)

Build LaserWeb Docker Image for Raspberry Pi (RPi2, RPi3, RPi4) #5

Workflow file for this run

name: Build LaserWeb Docker Image for Raspberry Pi (RPi2, RPi3, RPi4)
env:
REGISTRY: ghcr.io
NAME: lwcomm
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- '.github/workflows/*lwcomm*'
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/*lwcomm*'
schedule:
- cron: '23 1 * * 0' # Sunday at 1:23
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set release date
run: |
echo "RELEASE_DATE=$(date --rfc-3339=date)" >> ${GITHUB_ENV}
- id: githubactor
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.actor }}
- id: step2
run: echo "IMAGE_NAME=ghcr.io/${{ steps.githubactor.outputs.lowercase }}/${{ env.NAME }}" >> ${GITHUB_ENV}
- name: Checkout builder factory repository
uses: actions/checkout@v3
- name: Clone LW Comm Server repository
run: |
git clone https://github.com/LaserWeb/lw.comm-server.git ./lw.comm-server
- name: Patch Dockerfile
run: |
# Remove the first line of the Dockerfile and add the new FROM line
sed -i '1s|.*|FROM node:10-alpine|' ./lw.comm-server/Dockerfile
# Immediately after FROM, add Python installation
sed -i '2i RUN apk add --no-cache python3 py3-pip' ./lw.comm-server/Dockerfile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image for RPi2, RPi3, and RPi4
uses: docker/build-push-action@v5
with:
context: ./lw.comm-server/
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.RELEASE_DATE }}
${{ env.IMAGE_NAME }}:latest
platforms: linux/arm/v7,linux/arm64/v8
labels: |
org.opencontainers.image.created=${{ env.RELEASE_DATE }}
org.opencontainers.image.version=latest