-
Notifications
You must be signed in to change notification settings - Fork 85
54 lines (45 loc) · 1.45 KB
/
build-docker-image.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
name: docker build
on:
push:
branches:
- 'production-live'
pull_request:
branches:
- 'production-live'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
# this workflow needs app source and Dockerfile to build image
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
# identify commit
- name: Print commit id and message
run: |
git show -s --format='%h %s'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
id: docker_build
with:
context: .
file: ./Dockerfile.prod
build-args: |
"ARG_DATABASE_URL=${{ secrets.NPB_DATABASE_URL }}"
"ARG_NEXTAUTH_URL=${{ secrets.NPB_NEXTAUTH_URL }}"
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/nextjs-prisma-boilerplate:latest
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/nextjs-prisma-boilerplate:buildcache
cache-to: type=inline
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}