-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor lawndon-pi build and deployment
- Loading branch information
1 parent
476bd05
commit 5411a3c
Showing
20 changed files
with
453 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Build Lawndon | ||
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
build-lawndon: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Arduino cli | ||
uses: arduino/setup-arduino-cli@v2 | ||
|
||
- name: Install libraries | ||
run: | | ||
arduino-cli lib install IBusBM Servo | ||
- name: Compile Lawndon | ||
uses: arduino/compile-sketches@v1 | ||
with: | ||
fqbn: "arduino:avr:mega" | ||
libraries: | | ||
- name: IBusBM | ||
- name: Servo | ||
sketch-paths: | | ||
- ./lawndon | ||
enable-warnings-report: true | ||
verbose: false | ||
cli-compile-flags: | | ||
- --export-binaries | ||
- name: Package build | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
for dir in ./lawndon/build/*; do | ||
if [ -d "${dir}" ]; then | ||
tar -czvf "${dir}.tar.gz" -C "${dir}" . | ||
fi | ||
done | ||
- name: Release build | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: | | ||
lawndon/build/*.tar.gz | ||
build-lawndon-pi: | ||
runs-on: ubuntu-latest | ||
needs: build-lawndon | ||
env: | ||
WORKING_DIR: ./pi | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU for multi-platform builds | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
buildkitd-flags: --allow-insecure-entitlement security.insecure | ||
install: true | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push server image | ||
uses: docker/build-push-action@v4 | ||
working-directory: ${{ env.WORKING_DIR }} | ||
with: | ||
context: . | ||
file: ./Dockerfile.server | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/lawndon-pi-server:${{ github.ref_name }} | ||
ghcr.io/${{ github.repository_owner }}/lawndon-pi-server:${{ github.sha }} | ||
- name: Build and push UI image | ||
uses: docker/build-push-action@v4 | ||
working-directory: ${{ env.WORKING_DIR }} | ||
with: | ||
context: . | ||
file: ./Dockerfile.ui | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/lawndon-pi-ui:${{ github.ref_name }} | ||
ghcr.io/${{ github.repository_owner }}/lawndon-pi-ui:${{ github.sha }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Build stage | ||
FROM node:22-alpine AS build | ||
WORKDIR /usr/src/app | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
ENV NODE_ENV=production | ||
ENV CONFIG_PATH=/usr/src/app/config | ||
|
||
RUN corepack enable | ||
COPY server/package*.json ./ | ||
RUN pnpm install | ||
|
||
COPY server ./server | ||
WORKDIR /usr/src/app/server | ||
RUN pnpm build | ||
|
||
# Runtime stage | ||
FROM node:22-alpine | ||
WORKDIR /usr/src/app | ||
|
||
COPY --from=build /usr/src/app/server/dist ./dist | ||
COPY --from=build /usr/src/app/server/node_modules ./node_modules | ||
COPY config ./config | ||
|
||
EXPOSE 5000 8080 | ||
CMD ["node", "dist/server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Build stage | ||
FROM node:22-alpine AS build | ||
WORKDIR /usr/src/app | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
ENV VITE_NODE_ENV=production | ||
|
||
RUN corepack enable | ||
COPY ui/package*.json ./ | ||
RUN pnpm install | ||
|
||
COPY ui ./ui | ||
WORKDIR /usr/src/app/ui | ||
RUN pnpm build | ||
|
||
# Runtime stage | ||
FROM nginx:alpine | ||
COPY --from=build /usr/src/app/ui/dist /usr/share/nginx/html | ||
|
||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
services: | ||
server: | ||
image: ghcr.io/jordojordo/lawndon-pi-server:latest | ||
environment: | ||
NODE_ENV: production | ||
CONFIG_PATH: /usr/src/app/config | ||
ports: | ||
- "5000:5000" # WebSocket and API | ||
- "8080:8080" # ESP32 module communication | ||
volumes: | ||
- ./config:/usr/src/app/config:ro # Mount config for anchor positions | ||
networks: | ||
- app_network | ||
|
||
ui: | ||
image: ghcr.io/jordojordo/uwb-ui:latest | ||
environment: | ||
VITE_NODE_ENV: production | ||
ports: | ||
- "80:80" # Expose UI | ||
depends_on: | ||
- server | ||
networks: | ||
- app_network | ||
|
||
networks: | ||
app_network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
NODE_ENV="development" | ||
CONFIG_PATH="../../config" | ||
UI_PATH="../../ui" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
NODE_ENV="production" | ||
CONFIG_PATH="../config" | ||
UI_PATH="../ui" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.