Add GitHub action example (#1)
This commit is contained in:
54
.github/workflows/image-ci.yml
vendored
Normal file
54
.github/workflows/image-ci.yml
vendored
Normal 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'
|
||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version
|
# Pin specific version
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version
|
# Pin specific version
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
# Specify working directory other than /
|
# Specify working directory other than /
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version for stability
|
# Pin specific version for stability
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
# Specify working directory other than /
|
# Specify working directory other than /
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version for stability
|
# Pin specific version for stability
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
# Specify working directory other than /
|
# Specify working directory other than /
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version for stability
|
# Pin specific version for stability
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
# Set NODE_ENV
|
# Set NODE_ENV
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version for stability
|
# Pin specific version for stability
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
# Set NODE_ENV
|
# Set NODE_ENV
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version for stability
|
# Pin specific version for stability
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
# Set NODE_ENV
|
# Set NODE_ENV
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Pin specific version for stability
|
# Pin specific version for stability
|
||||||
# Use alpine for reduced image size
|
# Use alpine for reduced image size
|
||||||
FROM node:19.4-alpine
|
FROM node:19.6-alpine
|
||||||
|
|
||||||
# Set NODE_ENV
|
# Set NODE_ENV
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
# syntax=docker/dockerfile:1.5
|
|
||||||
|
|
||||||
FROM node:19.4-bullseye AS build
|
FROM node:19.4-bullseye AS build
|
||||||
|
|
||||||
# Specify working directory other than /
|
# Specify working directory other than /
|
||||||
|
|||||||
Reference in New Issue
Block a user