From b6723c1836a556b392a5742350fd526975b01f20 Mon Sep 17 00:00:00 2001
From: Pascal Syma
Date: Sun, 3 Aug 2025 19:16:33 +0200
Subject: [PATCH] Add CD
---
.dockerignore | 12 +++++++++
.github/workflows/docker.yml | 48 ++++++++++++++++++++++++++++++++++++
Dockerfile | 48 ++++++++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+)
create mode 100644 .dockerignore
create mode 100644 .github/workflows/docker.yml
create mode 100644 Dockerfile
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..f0031ac
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,12 @@
+.gitignore
+.git
+.idea
+.output
+.nuxt
+.env
+.env.example
+.prettierignore
+.prettierrc.json
+docker-compose.*
+Dockerfile
+*.md
\ No newline at end of file
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 0000000..7b895db
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,48 @@
+name: Docker Image CI
+
+on:
+ push:
+ pull_request:
+ branches: ['main']
+
+jobs:
+ deploy:
+ permissions:
+ contents: read
+ packages: write
+ attestations: write
+ id-token: write
+ runs-on: ubuntu-latest
+ env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: ${{ github.repository }}
+ if: github.ref == 'refs/heads/main'
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: Login to Github Packages
+ uses: docker/login-action@v1
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Extract metadata for Docker
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ tags: |
+ # set latest tag for default branch
+ type=raw,value=latest,enable={{is_default_branch}}
+ type=semver,pattern={{version}}
+ - name: Build and push
+ id: push
+ uses: docker/build-push-action@v3
+ with:
+ context: '.'
+ file: 'Dockerfile'
+ push: true
+ pull: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..0c08080
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,48 @@
+# syntax = docker/dockerfile:1
+
+ARG BUN_VERSION=1.2.19
+
+# Build prisma
+FROM oven/bun:${BUN_VERSION} AS prisma
+WORKDIR /src
+
+COPY --link package.json ./package.json
+COPY --link bun.lock ./bun.lock
+
+COPY --link prisma ./prisma
+
+RUN apt-get update -y && apt-get install -y openssl
+RUN bun add prisma
+RUN bunx --bun prisma generate
+
+FROM oven/bun:${BUN_VERSION} AS base
+
+ENV NODE_ENV=production
+
+WORKDIR /src
+
+# Build
+FROM base AS build
+
+COPY --link package.json bun.lock ./
+
+RUN bun install --include=dev
+COPY --from=prisma /src/node_modules/.prisma node_modules/.prisma
+COPY --from=prisma /src/node_modules/@prisma node_modules/@prisma
+
+COPY --link . .
+
+RUN bun run build -- --preset bun
+
+# Run
+FROM base
+
+RUN apt-get update && apt-get -y install curl
+
+HEALTHCHECK CMD curl --fail http://localhost:3000/api-health || exit 1
+
+COPY --from=build /src/.output .
+
+CMD ["bun", "run", "./server/index.mjs" ]
+
+LABEL org.opencontainers.image.source=https://github.com/PassiDel/pichunt
\ No newline at end of file