Skip to content

docker build

docker build #34

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 }}