Skip to content

Commit

Permalink
Update Docker nginx version and add github action to build and push d…
Browse files Browse the repository at this point in the history
…ocker image to ghcr.io
  • Loading branch information
stuartcaunt committed Jan 6, 2025
1 parent bbe5ea2 commit 317f8e7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and push docker image

on:
push:
branches: [ "dev" ]
tags: [ "*.*.*" ]
pull_request:
branches: [ "dev" ]

jobs:
docker:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context : .
file : ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: Trigger external deploy pipeline
if: success()
run: |
if [ -z "${{ secrets.DEPLOY_PIPELINE_URL }}" ]; then
echo "Error: DEPLOY_PIPELINE_URL is not set"
else
curl -X POST "${{ secrets.DEPLOY_PIPELINE_URL }}"
fi
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# stage1 as builder
FROM node:14-alpine as builder
FROM node:20-alpine AS builder

WORKDIR /app

Expand All @@ -10,7 +10,7 @@ RUN npm install
RUN npm run build

# stage2 package with nginx
FROM nginx:1.19.0-alpine
FROM nginx:1.27.2-alpine3.20

COPY nginx/default.conf /etc/nginx/conf.d/

Expand Down

0 comments on commit 317f8e7

Please sign in to comment.