Skip to content

Build Application Docker #13

Build Application Docker

Build Application Docker #13

on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: '0 9 1,10,20,30 * *'
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
name: Build Application Docker
env:
REGISTRY: ghcr.io
IMAGE_NAME: gravity-ui/node-nginx
NODE_VERSION: '20'
UBUNTU_VERSION: '22.04'
IMAGE_UBUNTU_NODE_VERSION: ubuntu22-nodejs20
jobs:
build:
name: docker-nodejs
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64'
- uses: docker/setup-buildx-action@v3
- name: 'Get release build date'
run: |
BUILD_DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d)
echo "Release build date: ${BUILD_DATE}"
echo "BUILD_DATE=$BUILD_DATE" >> "$GITHUB_ENV"
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags for Docker only Node.js
id: meta-node
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}.${{ env.BUILD_DATE }}
- name: Extract tags for Docker with Nginx and Node.js
id: meta-nginx
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-nginx
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-nginx.${{ env.BUILD_DATE }}
- name: Extract tags for Docker with additional packages
id: meta-full
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-full
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-full.${{ env.BUILD_DATE }}
- name: Build and push Docker only Node.js
uses: docker/[email protected]
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-node.outputs.tags }}
labels: ${{ steps.meta-node.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
NODE_VERSION=${{ env.NODE_VERSION }}
- name: Build and push Docker with Nginx and Node.js
uses: docker/[email protected]
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-nginx.outputs.tags }}
labels: ${{ steps.meta-nginx.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
NODE_VERSION=${{ env.NODE_VERSION }}
ADDITIONAL_PACKAGES=nginx supervisor
- name: Build and push Docker with additional packages
uses: docker/[email protected]
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-full.outputs.tags }}
labels: ${{ steps.meta-full.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
NODE_VERSION=${{ env.NODE_VERSION }}
ADDITIONAL_PACKAGES=nginx supervisor nano vim curl git telnet bzip2 iproute2 wget