Skip to content

Commit

Permalink
Build and push to GHCR on push to master
Browse files Browse the repository at this point in the history
  • Loading branch information
itswadesh committed Oct 3, 2024
1 parent 2373124 commit 0c5f6d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
33 changes: 11 additions & 22 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
name: Build app and push to GHCR
name: Build docker image and push to GHCR

on:
release:
types: [published]
push:
branches:
- master
workflow_dispatch:

jobs:
build-webapp:
build-www:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

# Build the app using nodejs
- name: Use node js 22
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install dependencies
run: npm install
- name: Build for production
run: npm run build

# Setup buildx in order to build for multiple platforms
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
- name: Setup Cache
uses: actions/setup-node@v4

# Extract metadata for the docker image
- name: Docker meta
Expand All @@ -50,13 +39,13 @@ jobs:
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
password: ${{ secrets.GH_TOKEN }}
# Build the docker image now
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }},ghcr.io/itswadesh/svelte-commerce:latest
tags: ${{ steps.meta.outputs.tags }},ghcr.io/itswadesh/svelte-commerce:1.0
labels: ${{ steps.meta.outputs.labels }}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Use an official Node.js runtime as a parent image
FROM node:22-alpine

LABEL author="Swadesh Behera"

# Set the working directory inside the container
Expand All @@ -9,7 +10,7 @@ WORKDIR /usr/src/app
COPY package*.json ./

# Install dependencies
RUN npm install --force
RUN npm install

# Copy the rest of your application's source code to the working directory
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"prettier-plugin-svelte": "^3.2.7",
"shelljs": "0.8.5",
"ssh2shell": "2.0.9",
"svelte": "^5.0.0-next.260",
"svelte": "^4.2.19",
"svelte-confetti": "^2.1.2",
"svelte-preprocess": "^6.0.3",
"svelte-share-buttons-component": "2.0.0",
Expand Down

0 comments on commit 0c5f6d6

Please sign in to comment.