-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (72 loc) · 2.55 KB
/
buildDocker.yml
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
name: Build Docker (manually)
# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
imageTag:
description: 'The tag to be used for the images'
required: true
default: 'latest'
env:
IMAGE_NAME_BASE: seerep_base
IMAGE_NAME_SERVER: seerep_server
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-docker:
runs-on: ubuntu-20.04
permissions:
packages: write
steps:
-
name: Generate tags base
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME_BASE
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# save to env for later steps
echo "image_id_base=$IMAGE_ID" >> $GITHUB_ENV
-
name: Generate tags server
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME_SERVER
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# save to env for later steps
echo "image_id_server=$IMAGE_ID" >> $GITHUB_ENV
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push base image
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
context: "{{defaultContext}}:docker/base"
tags: ${{ env.image_id_base }}:${{ github.event.inputs.imageTag }}
cache-from: type=registry,ref=${{ env.image_id_base }}:${{ github.event.inputs.imageTag }}
cache-to: type=inline
-
name: Build and push server image
uses: docker/build-push-action@v5
with:
push: true
file: docker/server/Dockerfile
tags: ${{ env.image_id_server }}:${{ github.event.inputs.imageTag }}
cache-from: type=registry,ref=${{ env.image_id_server }}:${{ github.event.inputs.imageTag }}
cache-to: type=inline
build-args: |
IMAGEBASE=${{ env.image_id_base }}
IMAGEBASETAG=${{ github.event.inputs.imageTag }}