Add GitHub action example (#1)

This commit is contained in:
sidpalas
2023-02-10 12:37:24 -05:00
committed by GitHub
parent c8aba89374
commit 6aaebbf876
10 changed files with 62 additions and 10 deletions

54
.github/workflows/image-ci.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: image-ci
on:
push:
branches:
- 'main'
- 'github-action'
tags:
- 'v*'
jobs:
build-tag-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
sidpalas/devops-directive-docker-course-api-node
tags: |
type=raw,value=latest
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
file: ./06-building-container-images/api-node/Dockerfile.8
context: ./05-example-web-application/api-node/
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'sidpalas/devops-directive-docker-course-api-node:latest'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL'

View File

@ -1,6 +1,6 @@
# Pin specific version
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
COPY . .

View File

@ -1,6 +1,6 @@
# Pin specific version
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
# Specify working directory other than /
WORKDIR /usr/src/app

View File

@ -1,6 +1,6 @@
# Pin specific version for stability
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
# Specify working directory other than /
WORKDIR /usr/src/app

View File

@ -1,6 +1,6 @@
# Pin specific version for stability
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
# Specify working directory other than /
WORKDIR /usr/src/app

View File

@ -1,6 +1,6 @@
# Pin specific version for stability
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
# Set NODE_ENV
ENV NODE_ENV production

View File

@ -1,6 +1,6 @@
# Pin specific version for stability
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
# Set NODE_ENV
ENV NODE_ENV production

View File

@ -1,6 +1,6 @@
# Pin specific version for stability
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
# Set NODE_ENV
ENV NODE_ENV production

View File

@ -1,6 +1,6 @@
# Pin specific version for stability
# Use alpine for reduced image size
FROM node:19.4-alpine
FROM node:19.6-alpine
# Set NODE_ENV
ENV NODE_ENV production

View File

@ -1,5 +1,3 @@
# syntax=docker/dockerfile:1.5
FROM node:19.4-bullseye AS build
# Specify working directory other than /