Skip to content

Commit

Permalink
👷 Add CI for building docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianpb committed Mar 4, 2024
1 parent fb17c5c commit 2cce47e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: Build & publish

on:
push:
# Sequence of patterns matched against refs/heads
branches:
- "**" # Push events on all branchs
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
publish:
name: Build package
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: 🏗 Build html
run: make build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64,arm32v6,arm32v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: prod
build-args:
app_path=rhasspy-handler
NPM_VERBOSE=1
8 changes: 0 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
FROM node:20 as development

ARG NPM_VERBOSE
ARG port
ARG app_path

# Base dir /app
Expand All @@ -25,9 +24,6 @@ VOLUME /${app_path}/data

COPY tsconfig.json ./

# Expose the listening port of your app
EXPOSE ${port}

CMD ["npm","run", "dev"]

##########################
Expand All @@ -48,7 +44,6 @@ RUN npm run build && tar czvf dist.tar.gz dist
# Step 4: "production" target #
###############################
FROM node:20-alpine3.18 as production
ARG port
ARG app_path

WORKDIR /$app_path
Expand All @@ -68,7 +63,4 @@ RUN apk --no-cache add curl tar && \
tar -zxvf dist.tar.gz && \
rm -rf dist.tar.gz && apk del tar

# Expose the listening port of your app
EXPOSE ${port}

CMD ["npm","run", "start"]
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Directory to save podcast
# Mopidy saves this in /var/lib/mopidy/media
export APP = rhasspyhandler
export APP = rhasspy-handler
export APP_PATH := $(shell pwd)
export PODCAST_DIR=media
export NPM_VERBOSE ?= 1
export DEVICE=raspberry
export PORT=8000

dummy := $(shell touch artifacts)
include ./artifacts
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ services:
app_path: /${APP}
NPM_VERBOSE: ${NPM_VERBOSE}
environment:
- port=${PORT}
- app_path=${APP}
- PODCAST_DIR=${PODCAST_DIR}
- DEVICE=${DEVICE}
Expand Down

0 comments on commit 2cce47e

Please sign in to comment.