-
Notifications
You must be signed in to change notification settings - Fork 1.3k
110 lines (94 loc) · 3.16 KB
/
docker-build-web.yml
File metadata and controls
110 lines (94 loc) · 3.16 KB
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
name: "Docker Build Web"
on:
workflow_dispatch:
inputs:
tag:
description: "Tag for the Docker image"
required: false
default: "latest"
type: string
jobs:
build:
name: Build Docker Image (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- platform: amd64
runner: ubuntu-24.04
- platform: arm64
runner: ubuntu-24.04-arm
fail-fast: false
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create .env file
run: |
echo "WEB_URL=http://localhost:3000" > .env
echo "NEXT_PUBLIC_DOCKER_BUILD=true" >> .env
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Downcase GITHUB_REPOSITORY_OWNER
run: |
echo "REPOSITORY_OWNER=${GITHUB_REPOSITORY_OWNER@L}" >>${GITHUB_ENV}
- name: Build and Push Platform Image
id: build
uses: docker/build-push-action@v5
with:
context: .
file: apps/web/Dockerfile
platforms: linux/${{ matrix.platform }}
push: true
outputs: type=image,name=ghcr.io/${{ env.REPOSITORY_OWNER }}/cap-web,push-by-digest=true
cache-from: type=gha,scope=buildx-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=buildx-${{ matrix.platform }}
- name: Export Digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload Digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Create Multi-Architecture Manifest
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Download Digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Downcase GITHUB_REPOSITORY_OWNER
run: |
echo "REPOSITORY_OWNER=${GITHUB_REPOSITORY_OWNER@L}" >>${GITHUB_ENV}
- name: Create Image Manifest
run: |
docker buildx imagetools create -t ghcr.io/${{ env.REPOSITORY_OWNER }}/cap-web:${{ inputs.tag || 'latest' }} \
$(find /tmp/digests -type f -not -path "*/\.*" -exec basename {} \; | xargs -I {} echo "ghcr.io/${{ env.REPOSITORY_OWNER }}/cap-web@sha256:{}")