Skip to content

Docker and CI/CD support with prisma, postgresql and elasticsearch #6

Docker and CI/CD support with prisma, postgresql and elasticsearch

Docker and CI/CD support with prisma, postgresql and elasticsearch #6

name: Build and Test Dev Docker
on:
push:
branches:
- dev
pull_request:
branches:
- dev
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: SageSeekerSociety/cheese_backend_prod
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to docker registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v5
with:
context: .
target: dev
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Create env file
run: cp sample.env .env
- name: Set up Docker Compose
uses: isbang/[email protected]
with:
down-flags: "--volumes"
- name: Initialize Database Structures with Prisma
run: docker compose exec backend pnpm prisma db push
- name: Run Test
run: docker compose exec backend pnpm run test:cov