17
17
# Docker and environment configs
18
18
- ' Dockerfile*'
19
19
- ' docker-compose.yml'
20
+ - ' docker-bake.hcl'
20
21
- ' .dockerignore'
21
22
- ' .env.example'
22
23
# Dependencies and python configs
38
39
env :
39
40
REGISTRY_URL : ghcr.io
40
41
REGISTRY_USER : ${{ github.repository_owner }}
41
- IMAGE : ${{ vars.IMAGE }}
42
+ IMAGE_NAME : ${{ vars.IMAGE || 'meetup_bot' }}
42
43
43
44
jobs :
44
- push_to_registry :
45
- name : Push Docker image to container registry
46
- # if: |
47
- # (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) ||
48
- # (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
45
+ build-and-push :
46
+ name : Build and push Docker image
49
47
runs-on : ubuntu-latest
50
- strategy :
51
- matrix :
52
- dockerfile : [Dockerfile.web]
53
48
concurrency :
54
49
group : ${{ github.workflow }}-${{ github.ref }}
55
50
cancel-in-progress : true
72
67
uses : docker/metadata-action@v5
73
68
with :
74
69
images : |
75
- name= ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ env.IMAGE }}
70
+ ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ env.IMAGE_NAME }}
76
71
tags : |
77
72
type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }}
78
73
type=ref,event=branch,enable=${{ !endsWith(github.ref, 'main') }}
@@ -88,21 +83,24 @@ jobs:
88
83
- name : Set up Docker Buildx
89
84
uses : docker/setup-buildx-action@v3
90
85
with :
91
- # Use native builders if available
92
86
platforms : linux/amd64,linux/arm64
93
87
94
- - name : Build and push Docker image
95
- uses : docker/build-push- action@v6
88
+ - name : Build and push with Docker Bake
89
+ uses : docker/bake- action@v4
96
90
with :
97
- context : .
98
- file : ${{ matrix.dockerfile }}
91
+ files : |
92
+ ./docker-bake.hcl
93
+ ${{ steps.meta.outputs.bake-file }}
94
+ targets : multi-platform
99
95
push : ${{ github.event_name != 'pull_request' }}
100
- tags : ${{ steps.meta.outputs.tags }}
101
- labels : ${{ steps.meta.outputs.labels }}
102
- platforms : linux/amd64,linux/arm64/v8
103
- cache-from : |
104
- type=gha,scope=${{ github.workflow }}
105
- type=registry,ref=ghcr.io/${{ env.REGISTRY_USER }}/${{ env.IMAGE }}:buildcache
106
- cache-to : |
107
- type=gha,scope=${{ github.workflow }},mode=max
108
- type=registry,ref=ghcr.io/${{ env.REGISTRY_USER }}/${{ env.IMAGE }}:buildcache,mode=max
96
+ set : |
97
+ *.cache-from=type=gha,scope=${{ github.workflow }}
98
+ *.cache-to=type=gha,mode=max,scope=${{ github.workflow }}
99
+ *.platform=linux/amd64,linux/arm64
100
+ *.args.PYTHON_VERSION=3.11
101
+ *.args.PORT=3100
102
+ REGISTRY_URL=${{ env.REGISTRY_URL }}
103
+ REGISTRY_USER=${{ env.REGISTRY_USER }}
104
+ IMAGE_NAME=${{ env.IMAGE_NAME }}
105
+ TAG=${{ steps.meta.outputs.version }}
106
+ DOCKERFILE=Dockerfile.web
0 commit comments