-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (107 loc) · 3.86 KB
/
build_application_docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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