Skip to content

♻️ build image outside of docker #10

♻️ build image outside of docker

♻️ build image outside of docker #10

name: Build and Push gh-next Images
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-push-web:
name: Build and Push web app
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache nextjs build output
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm -lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 8.15.9
- name: Use Node.js version 20.x
uses: actions/setup-node@v2
with:
node-version: 20.x
cache: 'pnpm'
- name: Build app with node
run: |
FORCE_COLOR=true pnpm install --shamefully-hoist --strict-peer-dependencies=false --frozen-lockfile
FORCE_COLOR=true SKIP_ENV_VALIDATION=1 pnpm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REGISTRY_PAT }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile.prod
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/fredkiss3/gh-next:latest,ghcr.io/fredkiss3/gh-next:${{ github.sha }}
cache-from: type=registry,ref=ghcr.io/fredkiss3/gh-next:latest
cache-to: type=inline
build-push-redis:
name: Build and Push Redis container
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REGISTRY_PAT }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile.redis
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/fredkiss3/webdis:latest,ghcr.io/fredkiss3/webdis:${{ github.sha }}
cache-from: type=registry,ref=ghcr.io/fredkiss3/webdis:latest
cache-to: type=inline